Socket
Socket
Sign inDemoInstall

bower-requirejs

Package Overview
Dependencies
Maintainers
3
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bower-requirejs - npm Package Compare versions

Comparing version 0.8.2 to 0.8.4

25

bin/bower-requirejs.js
#!/usr/bin/env node
'use strict';
var nopt = require('nopt');

@@ -17,3 +16,3 @@ var path = require('path');

exclude: Array,
baseurl: path
baseUrl: path
}, {

@@ -24,3 +23,3 @@ h: '--help',

e: '--exclude',
b: '--baseurl'
b: '--baseUrl'
});

@@ -30,7 +29,7 @@

function init () {
function init() {
project(args, opts);
}
function help () {
function help() {
var out = [

@@ -42,5 +41,5 @@ 'Usage: bower-requirejs [options]',

' -v, --version # Print the version number',
' -c, --config # Path to your requirejs config file',
' -e, --exclude # Name of a dependency to be excluded from the process',
' -b, --baseurl # Path which all dependencies will be relative to',
' -c, --config # Path to your RequireJS config file',
' -e, --exclude # Name of a dependency to be excluded from the process',
' -b, --baseUrl # Path which all dependencies will be relative to',
''

@@ -54,3 +53,3 @@ ];

var msg = [
chalk.red('Easy with the "sudo."'),
chalk.red('Easy with the `sudo` :)'),
'Since bower-requirejs is a user command, there is no need to execute it with superuser',

@@ -65,3 +64,3 @@ 'permissions. If you\'re having permission errors when using bower-requirejs without sudo',

sudoBlock({ message: msg.join('\n') });
sudoBlock({message: msg.join('\n')});
}

@@ -78,10 +77,6 @@

if (!opts.config) {
return console.log('--config option is required');
}
init();
}
if (!process.env.yeoman_test && opts['update-notifier'] !== false) {
if (opts['update-notifier'] !== false) {
var notifier = updateNotifier({

@@ -88,0 +83,0 @@ packagePath: '../package.json'

31

lib/index.js
'use strict';
var path = require('path');
var fs = require('fs');
var file = require('file-utils');
var requirejs = require('requirejs/bin/r.js');

@@ -15,3 +16,2 @@ var _ = require('lodash');

*/
module.exports = function (args, opts, done) {

@@ -21,13 +21,22 @@ args = args || [];

var config = opts.config;
if (!config) {
var configPath = opts.config;
if (!configPath) {
throw new Error('--config option is required');
}
var configDir = path.dirname(config);
var configDir = path.dirname(configPath);
var exclude = opts.exclude || [];
var baseUrl = opts.baseUrl || configDir;
var file = fs.readFileSync(String(config), 'utf8');
function run () {
require('bower').commands.list({ paths: true, relative: false })
// Grab the config file, or create one if it doesn't exist
var config;
if (file.exists(configPath)) {
config = fs.readFileSync(String(configPath), 'utf8');
} else {
config = fs.readFileSync(path.join(__dirname, '../templates/config.js'), 'utf8');
}
function run() {
require('bower').commands.list({paths: true, relative: false})
.on('end', function (data) {

@@ -49,3 +58,2 @@ if (data) {

*/
function makeDependencies (data) {

@@ -57,2 +65,3 @@ var dependencies = {};

}
var dep = parse(val, key, baseUrl);

@@ -70,7 +79,6 @@ if (dep) {

*/
function writeConfig (dependencies) {
var rjsConfig;
requirejs.tools.useLib(function (require) {
rjsConfig = require('transform').modifyConfig(file, function (config) {
rjsConfig = require('transform').modifyConfig(config, function (config) {

@@ -89,4 +97,5 @@ // If the original config defines paths, add the

fs.writeFileSync(config, rjsConfig, 'utf-8');
fs.writeFileSync(configPath, rjsConfig, 'utf-8');
console.log(success('Updated RequireJS config with installed Bower components'));
if (!done) {

@@ -93,0 +102,0 @@ done = function () {};

@@ -14,3 +14,2 @@ 'use strict';

*/
module.exports = function (dep, name, baseUrl) {

@@ -21,4 +20,3 @@

*/
function dependency () {
function dependency() {
// If the dependency is a directory

@@ -52,4 +50,3 @@ if (_.isString(dep) && file.isDir(dep)) {

*/
function filter (arr) {
function filter(arr) {
var jsfiles = _.filter(arr, function (val) {

@@ -65,4 +62,3 @@ return path.extname(val) === '.js';

*/
function paths () {
function paths() {
var dependencies = {};

@@ -80,4 +76,3 @@ var resolve = resolver(dependencies);

*/
function resolver (dependencies) {
function resolver(dependencies) {
return function (val, index, arr) {

@@ -95,4 +90,3 @@ if (arr.length > 1) {

*/
function dependencyByFilename (val) {
function dependencyByFilename(val) {
var dep = {};

@@ -108,4 +102,3 @@ var name = getName(path.basename(val));

*/
function dependencyByComponentName (componentName, val) {
function dependencyByComponentName(componentName, val) {
var dep = {};

@@ -122,4 +115,3 @@ var name = getName(componentName);

*/
function getName (name) {
function getName(name) {
return filterName(name, 'js', 'min');

@@ -132,4 +124,3 @@ }

*/
function getPath (val) {
function getPath(val) {
var filepath = relative(removeExtension(val, 'js'));

@@ -143,4 +134,3 @@ filepath = normalizePath(filepath);

*/
function removeExtension (filepath, extension) {
function removeExtension(filepath, extension) {
var newPath;

@@ -159,4 +149,3 @@ if (extension[0] !== '.') {

*/
function filterName () {
function filterName() {
var oldName = arguments[0];

@@ -183,4 +172,3 @@ var newName = _.difference(oldName.split('.'), slice.call(arguments, 1));

*/
function normalizePath (str) {
function normalizePath(str) {
return process.platform === 'win32' ? slash(str) : str;

@@ -194,3 +182,2 @@ }

*/
function relative (filepath) {

@@ -197,0 +184,0 @@ return path.relative(baseUrl, filepath);

@@ -14,3 +14,2 @@ 'use strict';

*/
module.exports = function (name, dep) {

@@ -21,4 +20,3 @@

*/
function excludeGrunt () {
function excludeGrunt() {
if (_.contains(main, 'grunt.js') || _.contains(main, 'Gruntfile.js')) {

@@ -36,4 +34,3 @@ console.log(warn('WARN'), 'Ignoring Gruntfile in ' + name);

*/
function findByDirname () {
function findByDirname() {
if (_.contains(main, path.basename(dep) + '.js')) {

@@ -48,4 +45,3 @@ main = [path.basename(dep) + '.js'];

*/
function findByDirnameSuffix () {
function findByDirnameSuffix() {
if (_.contains(main, path.basename(dep).replace(/js$/, '') + '.js')) {

@@ -59,4 +55,3 @@ main = [path.basename(dep).replace(/js$/, '') + '.js'];

*/
function findByPackage () {
function findByPackage() {
var pkgPath = path.join(dep, 'package.json');

@@ -76,4 +71,3 @@ if (file.exists(pkgPath)) {

*/
function until (test, callbacks, done) {
function until(test, callbacks, done) {
for (var i = 0; i < callbacks.length; i++) {

@@ -93,4 +87,3 @@ if (test()) {

*/
function primaryFound () {
function primaryFound() {
return main.length === 1;

@@ -103,4 +96,3 @@ }

*/
function end () {
function end() {
if (primaryFound()) {

@@ -107,0 +99,0 @@ dep = path.join(dep, main[0]);

{
"name": "bower-requirejs",
"version": "0.8.2",
"version": "0.8.4",
"description": "Automagically wire-up installed Bower components into your RequireJS config",

@@ -11,2 +11,3 @@ "keywords": [

"wire",
"inject",
"install",

@@ -17,4 +18,2 @@ "component",

],
"homepage": "https://github.com/yeoman/bower-requirejs",
"bugs": "https://github.com/yeoman/bower-requirejs/issues",
"license": "BSD",

@@ -44,6 +43,3 @@ "author": {

},
"repository": {
"type": "git",
"url": "git://github.com/yeoman/bower-requirejs.git"
},
"repository": "yeoman/bower-requirejs",
"scripts": {

@@ -56,21 +52,22 @@ "test": "grunt test"

"nopt": "~2.1.2",
"lodash": "~1.3.1",
"chalk": "~0.2.1",
"lodash": "~2.4.1",
"chalk": "~0.3.0",
"glob": "~3.2.6",
"file-utils": "~0.1.2",
"sudo-block": "~0.2.1",
"sudo-block": "~0.3.0",
"update-notifier": "~0.1.7"
},
"devDependencies": {
"matchdep": "~0.1.1",
"grunt": "~0.4.0",
"grunt-contrib-jshint": "~0.6.2",
"grunt-contrib-jshint": "~0.7.2",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-copy": "~0.4.0",
"grunt-contrib-nodeunit": "~0.2.0",
"grunt-simple-mocha": "~0.4.0",
"bower": "~1.x",
"durable-json-lint": "0.0.1",
"mocha": "~1.12.1",
"grunt-simple-mocha": "~0.4.0",
"should": "~1.2.2"
"mocha": "~1.15.1",
"should": "~2.1.1",
"load-grunt-tasks": "~0.2.0",
"mockery": "~1.4.0"
},

@@ -77,0 +74,0 @@ "peerDependencies": {

# bower-requirejs [![Build Status](https://secure.travis-ci.org/yeoman/bower-requirejs.png?branch=master)](http://travis-ci.org/yeoman/bower-requirejs)
Automagically wire-up installed Bower components into your RequireJS config
> Automagically wire-up installed Bower components into your RequireJS config

@@ -10,2 +10,3 @@

## Example usage

@@ -17,2 +18,3 @@

## Options

@@ -23,7 +25,8 @@

-v, --version # Print the version number'
-c, --config # Path to your requirejs config file'
-e, --excludes # Name of a dependency to be excluded from the process'
-b, --baseurl # Path which all dependencies will be relative to'
-c, --config # Path to your RequireJS config file'
-e, --exclude # Name of a dependency to be excluded from the process'
-b, --baseUrl # Path which all dependencies will be relative to'
```
## Things to remember

@@ -33,7 +36,7 @@

You need to already have a `config.js` file at the location specified by the `--config` option. At a minimum, the file should look like this:
If you do not already have a `config.js` file at the location specified by the `--config` option then one will be generated for you. A basic `config.js` file looks like this:
``` js
requirejs.config({
baseUrl: './',
shim: {},
paths: {}

@@ -43,9 +46,9 @@ });

You still need to create a path for *your* js files. The grunt task will only create paths for third party libraries specified in `bower.json`.
You still need to create a path for *your* js files. This tool will only create paths for third party libraries specified in `bower.json`.
``` js
requirejs.config({
baseUrl: './',
shim: {},
paths: {
myComponent: 'js/myComponent.js'
myComponent: 'js/myComponent.js' // make sure to add your components!
}

@@ -55,4 +58,5 @@ });

The task does not overwrite the config file, it just adds additional paths to it. So paths you add will be preserved. Keep in mind that if you change or remove one of your bower dependencies after you've run the task, that path will still exist in the config file and you'll need to manually remove it.
The tool does not overwrite the config file, it just adds additional paths to it. So paths you add will be preserved. Keep in mind that if you change or remove one of your Bower dependencies after you've run the task, that path will still exist in the config file and you'll need to manually remove it.
### RequireJS component

@@ -63,4 +67,11 @@

## Credit
[![Sindre Sorhus](http://gravatar.com/avatar/d36a92237c75c5337c17b60d90686bf9?s=144)](http://sindresorhus.com) | [![Rob Dodson](http://gravatar.com/avatar/95c3a3b33ea51545229c625bef42e343?s=144)](http://robdodson.me)
:---:|:---:
[Sindre Sorhus](http://sindresorhus.com) (creator) | [Rob Dodson](http://robdodson.me) (maintainer)
## License
[BSD license](http://opensource.org/licenses/bsd-license.php) and copyright Google
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc