mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 03:17:49 +00:00
Rename Minify to minify.
Former-commit-id: 595b9dbeab4f2822626c74a18379262a8d583cfd
This commit is contained in:
@@ -29,18 +29,29 @@
|
|||||||
'--warning_level=QUIET'
|
'--warning_level=QUIET'
|
||||||
];
|
];
|
||||||
|
|
||||||
/** Used to match the file extension of a file path */
|
|
||||||
var reExtension = /\.[^.]+$/;
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Minify a given JavaScript `source`.
|
* The exposed `minify` function minifies a given `source` and invokes the
|
||||||
|
* `onComplete` callback when finished.
|
||||||
*
|
*
|
||||||
* @param {String} source The source to minify.
|
* @param {String} source The source to minify.
|
||||||
* @param {String} workingName The name to give temporary files creates during the minification process.
|
* @param {String} workingName The name to give temporary files creates during the minification process.
|
||||||
* @param {Function} onComplete A function called when minification has completed.
|
* @param {Function} onComplete A function called when minification has completed.
|
||||||
*/
|
*/
|
||||||
|
function minify(source, workingName, onComplete) {
|
||||||
|
new Minify(source, workingName, onComplete);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Minify constructor used to keep state of each `minify` invocation.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @constructor
|
||||||
|
* @param {String} source The source to minify.
|
||||||
|
* @param {String} workingName The name to give temporary files creates during the minification process.
|
||||||
|
* @param {Function} onComplete A function called when minification has completed.
|
||||||
|
*/
|
||||||
function Minify(source, workingName, onComplete) {
|
function Minify(source, workingName, onComplete) {
|
||||||
// create the destination directory if it doesn't exist
|
// create the destination directory if it doesn't exist
|
||||||
if (!path.existsSync(distPath)) {
|
if (!path.existsSync(distPath)) {
|
||||||
@@ -305,9 +316,9 @@
|
|||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
// expose `Minify`
|
// expose `minify`
|
||||||
if (module != require.main) {
|
if (module != require.main) {
|
||||||
module.exports = Minify;
|
module.exports = minify;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// read the JavaScript source file from the first argument if the script
|
// read the JavaScript source file from the first argument if the script
|
||||||
@@ -319,8 +330,8 @@
|
|||||||
source = fs.readFileSync(filePath, 'utf8'),
|
source = fs.readFileSync(filePath, 'utf8'),
|
||||||
workingName = path.basename(filePath, '.js') + '.min';
|
workingName = path.basename(filePath, '.js') + '.min';
|
||||||
|
|
||||||
new Minify(source, workingName, function(result) {
|
minify(source, workingName, function(result) {
|
||||||
fs.writeFileSync(path.join(dirPath, workingName + '.js'));
|
fs.writeFileSync(path.join(dirPath, workingName + '.js'), result);
|
||||||
});
|
});
|
||||||
}());
|
}());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user