mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 18:17:48 +00:00
Add "-o" and "--output" build options.
Former-commit-id: 154c0a6b749ff2439c024602fb9ec781e293f511
This commit is contained in:
16
build.js
16
build.js
@@ -746,8 +746,9 @@
|
|||||||
}, '');
|
}, '');
|
||||||
|
|
||||||
// used to report invalid command-line arguments
|
// used to report invalid command-line arguments
|
||||||
var invalidArgs = _.reject(options.slice(options[0] == 'node' ? 2 : 0), function(value, index) {
|
var invalidArgs = _.reject(options.slice(options[0] == 'node' ? 2 : 0), function(value, index, options) {
|
||||||
if (/^(?:category|exclude|exports|include)=.*$/.test(value)) {
|
if (/^(?:-o|--output)$/.test(options[index - 1]) ||
|
||||||
|
/^(?:category|exclude|exports|include)=.*$/.test(value)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return [
|
return [
|
||||||
@@ -765,6 +766,11 @@
|
|||||||
].indexOf(value) > -1;
|
].indexOf(value) > -1;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// used to specify the output path for built files
|
||||||
|
var outputPath = options.reduce(function(result, value, index) {
|
||||||
|
return result || (/^(?:-o|--output)$/.test(value) ? options[index + 1] : result);
|
||||||
|
}, '');
|
||||||
|
|
||||||
// load customized Lo-Dash module
|
// load customized Lo-Dash module
|
||||||
var lodash = (function() {
|
var lodash = (function() {
|
||||||
var context = vm.createContext({
|
var context = vm.createContext({
|
||||||
@@ -1275,7 +1281,7 @@
|
|||||||
// begin the minification process
|
// begin the minification process
|
||||||
if (!_.isEqual(exportsOptions, exportsAll) || filterType || isBackbone || isLegacy || isMobile || isStrict || isUnderscore) {
|
if (!_.isEqual(exportsOptions, exportsAll) || filterType || isBackbone || isLegacy || isMobile || isStrict || isUnderscore) {
|
||||||
// output debug build
|
// output debug build
|
||||||
if (!isStdOut) {
|
if (!outputPath && !isStdOut) {
|
||||||
callback(path.join(cwd, 'lodash.custom.js'), debugSource);
|
callback(path.join(cwd, 'lodash.custom.js'), debugSource);
|
||||||
}
|
}
|
||||||
minify(source, {
|
minify(source, {
|
||||||
@@ -1290,7 +1296,7 @@
|
|||||||
if (isStdOut) {
|
if (isStdOut) {
|
||||||
console.log(source);
|
console.log(source);
|
||||||
} else {
|
} else {
|
||||||
callback(path.join(cwd, 'lodash.custom.min.js'), source);
|
callback(outputPath || path.join(cwd, 'lodash.custom.min.js'), source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1304,7 +1310,7 @@
|
|||||||
if (isStdOut) {
|
if (isStdOut) {
|
||||||
console.log(source);
|
console.log(source);
|
||||||
} else {
|
} else {
|
||||||
callback(path.join(cwd, 'lodash.min.js'), source);
|
callback(outputPath || path.join(cwd, 'lodash.min.js'), source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user