Add help and version options to build.js.

Former-commit-id: 95a9fdaa7a00550922e71ce01a3f742b845d082c
This commit is contained in:
John-David Dalton
2012-07-12 13:26:14 -04:00
parent 61105e0679
commit 4293515b3d
2 changed files with 54 additions and 10 deletions

View File

@@ -75,23 +75,23 @@ lodash category=collections,functions
lodash category="collections, functions"
~~~
2. Use the `include` argument to pass the names of methods to include in the build.
~~~ bash
lodash include=each,filter,map
lodash include="each, filter, map"
~~~
3. Use the `exclude` argument to pass the names of methods to exclude from the build.
2. Use the `exclude` argument to pass the names of methods to exclude from the build.
~~~ bash
lodash exclude=union,uniq,zip
lodash exclude="union, uniq, zip"
~~~
All arguments, except `include` with `exclude` and `mobile` with `legacy`, may be combined.
3. Use the `include` argument to pass the names of methods to include in the build.
~~~ bash
lodash include=each,filter,map
lodash include="each, filter, map"
~~~
All arguments, except `exclude` with `include` and `legacy` with `mobile`, may be combined.
~~~ bash
lodash backbone mobile category=functions include=pick,uniq
lodash backbone legacy category=utilities exclude=first,last
lodash backbone mobile category=functions include=pick,uniq
~~~
The `lodash` command-line utility is available when Lo-Dash is installed as a global package (i.e. `npm install -g lodash`).

View File

@@ -29,7 +29,6 @@
/** Load customized Lo-Dash module */
var lodash = (function() {
var sandbox = {};
if (isLegacy) {
['isBindFast', 'isKeysFast', 'nativeBind', 'nativeIsArray', 'nativeKeys'].forEach(function(varName) {
source = replaceVar(source, varName, 'false');
@@ -261,6 +260,33 @@
/*--------------------------------------------------------------------------*/
/**
* Logs the help message to the console.
*
* @private
*/
function displayHelp() {
console.log([
'',
' Commands:',
'',
' lodash backbone Build containing all methods required by Backbone',
' lodash legacy Build tailored for older browsers without ES5 support',
' lodash mobile Build with IE < 9 bug fixes and method compilation removed',
' lodash category=... Comma separated categories of methods to include in the build',
' lodash exclude=... Comma separated names of methods to exclude from the build',
' lodash include=... Comma separated names of methods to include in the build',
'',
' All arguments, except `exclude` with `include` and `legacy` with `mobile`, may be combined.',
'',
' Options:',
'',
' -h, --help Display help information',
' -V, --version Output current version of Lo-Dash',
''
].join('\n'));
}
/**
* Gets the aliases associated with a given function name.
*
@@ -537,6 +563,24 @@
/*--------------------------------------------------------------------------*/
// display help message
if (lodash.find(process.argv, function(arg) {
return /^(?:-h|--help)$/.test(arg);
})) {
displayHelp();
process.exit();
}
// display `lodash.VERSION`
if (lodash.find(process.argv, function(arg) {
return /^(?:-V|--version)$/.test(arg);
})) {
console.log(lodash.VERSION);
process.exit();
}
/*--------------------------------------------------------------------------*/
// Backbone build
if (isBackbone) {
// add any additional sub-dependencies