mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 08:57:49 +00:00
Add help and version options to build.js.
Former-commit-id: 95a9fdaa7a00550922e71ce01a3f742b845d082c
This commit is contained in:
18
README.md
18
README.md
@@ -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`).
|
||||
|
||||
46
build.js
46
build.js
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user