bower-requirejs
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -18,3 +18,4 @@ #!/usr/bin/env node | ||
baseUrl: path, // alias for --base-url | ||
transitive: Boolean | ||
transitive: Boolean, | ||
'exclude-dev': Boolean | ||
}, { | ||
@@ -26,3 +27,4 @@ h: '--help', | ||
b: '--base-url', | ||
t: '--transitive' | ||
t: '--transitive', | ||
d: '--exclude-dev' | ||
}); | ||
@@ -43,8 +45,9 @@ | ||
'General options:', | ||
' -h, --help # Print options and usage', | ||
' -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, --base-url # Path which all dependencies will be relative to', | ||
' -t, --transitive # Process transitive dependencies', | ||
' -h, --help # Print options and usage', | ||
' -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, --base-url # Path which all dependencies will be relative to', | ||
' -t, --transitive # Process transitive dependencies', | ||
' -d, --exclude-dev # Exclude devDependencies', | ||
'' | ||
@@ -51,0 +54,0 @@ ]; |
@@ -14,3 +14,26 @@ 'use strict'; | ||
var baseUrl = opts.baseUrl || ''; | ||
var overrides = dependencyGraph.pkgMeta.overrides; | ||
// Override the main property of each direct dependency. | ||
if (overrides) { | ||
_.forOwn(overrides, function (dep, name) { | ||
if (dep.main) { | ||
var main = dep.main.trim(); | ||
var dependency = dependencyGraph.dependencies[name]; | ||
if (dependency && main) { | ||
dependency.pkgMeta.main = main; | ||
} | ||
} | ||
}); | ||
} | ||
// #84 exclude devDependencies | ||
if (opts['exclude-dev']) { | ||
exclude = _.chain(dependencyGraph.pkgMeta.devDependencies || {}) | ||
.reduce(function(exclude,val,key){ | ||
exclude.push(key); | ||
return exclude; | ||
},exclude).uniq().value(); | ||
} | ||
var dependencies = {}; | ||
@@ -22,3 +45,3 @@ // Recursively register dependencies if transitive option is specified. | ||
_.forOwn(node.dependencies, function (dep, name) { | ||
if (! _.has(dependencies, name)) { | ||
if (!_.has(dependencies, name)) { | ||
dependencies[name] = dep; | ||
@@ -50,3 +73,3 @@ registerTransitiveDependencies(dep); | ||
assign(config.paths, configElement.paths); | ||
} | ||
} | ||
if (configElement.package) { | ||
@@ -53,0 +76,0 @@ config.packages.push(configElement.package); |
@@ -18,2 +18,9 @@ 'use strict'; | ||
/** | ||
* Fixup slashes in file paths for windows | ||
*/ | ||
function normalizePath(str) { | ||
return process.platform === 'win32' ? slash(str) : str; | ||
} | ||
function parsePackage(dep, name, baseUrl) { | ||
@@ -47,3 +54,3 @@ var canonicalDir = dep.canonicalDir; | ||
main: main, | ||
location: location | ||
location: normalizePath(location) | ||
} | ||
@@ -206,9 +213,2 @@ }; | ||
/** | ||
* Fixup slashes in file paths for windows | ||
*/ | ||
function normalizePath(str) { | ||
return process.platform === 'win32' ? slash(str) : str; | ||
} | ||
/** | ||
* Combine the main.js file with its canonicalDir to | ||
@@ -215,0 +215,0 @@ * produce a full file path |
'use strict'; | ||
var path = require('path'); | ||
var slash = require('slash'); | ||
var _ = require('lodash'); | ||
@@ -24,2 +25,9 @@ var chalk = require('chalk'); | ||
/** | ||
* Fixup slashes in file paths for windows | ||
*/ | ||
function normalizePath(str) { | ||
return process.platform === 'win32' ? slash(str) : str; | ||
} | ||
/** | ||
* If we find any Gruntfiles, remove them and log a warning. | ||
@@ -122,5 +130,5 @@ */ | ||
var searchPath = path.join(dep.canonicalDir, searchDir); | ||
var candidateFiles = file.expand({ cwd: searchPath}, '*.js', '!*.min.js'); | ||
var candidateFiles = file.expand({ cwd: normalizePath(searchPath)}, '*.js', '!*.min.js'); | ||
_.each(candidateFiles, function (candidateFile) { | ||
main.push(path.join(searchDir, candidateFile)); | ||
main.push(normalizePath(path.join(searchDir, candidateFile))); | ||
}); | ||
@@ -127,0 +135,0 @@ }); |
{ | ||
"name": "bower-requirejs", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Automagically wire-up installed Bower components into your RequireJS config", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -23,8 +23,9 @@ # bower-requirejs [![Build Status](https://secure.travis-ci.org/yeoman/bower-requirejs.svg?branch=master)](http://travis-ci.org/yeoman/bower-requirejs) | ||
``` | ||
-h, --help # Print options and usage' | ||
-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, --base-url # Path which all dependencies will be relative to' | ||
-t, --transitive # Process transitive dependencies' | ||
-h, --help # Print options and usage' | ||
-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, --base-url # Path which all dependencies will be relative to' | ||
-t, --transitive # Process transitive dependencies' | ||
-d, --exclude-dev # Exclude devDependencies' | ||
``` | ||
@@ -81,3 +82,7 @@ | ||
### exclude-dev option | ||
If the `exclude-dev` option is set to ```true```, then dev-dependencies will not be added to the require config. | ||
### RequireJS component | ||
@@ -150,2 +155,22 @@ | ||
### Overriding the main file of a dependency | ||
You can override the main file of a given dependency by specifying the `overrides.{dependency}.main` property | ||
in your `bower.json` file: | ||
```js | ||
{ | ||
"overrides": { | ||
"jquery": { | ||
"main": "jquery.min.js" | ||
}, | ||
"anima": { | ||
"main": "anima.min.js" | ||
} | ||
} | ||
} | ||
``` | ||
> The file path is relative to the dependency folder | ||
## Programmatic API | ||
@@ -152,0 +177,0 @@ |
28085
596
270