Cleanup build files.

Former-commit-id: d19939a34688a8a63979f84eb1a5c5f9c926897b
This commit is contained in:
John-David Dalton
2012-09-30 01:55:26 -07:00
parent de821e55ae
commit 9cc11b8774
4 changed files with 25 additions and 19 deletions

View File

@@ -811,7 +811,7 @@
* Creates a debug and minified build, executing the `callback` for each.
* The `callback` is invoked with 2 arguments; (filePath, source)
*
* @param {Array} [options=[]] The build options array.
* @param {Array} [options=[]] An array of commands.
* @param {Function} callback The function called per build.
*/
function build(options, callback) {

View File

@@ -37,16 +37,16 @@
* The exposed `minify` function minifies a given Lo-Dash `source` and invokes
* the `onComplete` callback when finished.
*
* @param {Array|String} source The array of command-line arguments or the
* source to minify.
* @param {Object} options The options object containing `onComplete`,
* `silent`, and `workingName`.
* @param {Array|String} [source=''] THe source to minify or array of commands.
* @param {Object} [options={}] The options object.
*/
function minify(source, options) {
source || (source = '');
options || (options = {});
// juggle arguments
if (Array.isArray(source)) {
// convert the command-line arguments to an options object
// convert commands to an options object
options = source;
var filePath = options[options.length - 1],
dirPath = path.dirname(filePath),
@@ -62,7 +62,6 @@
var outputPath = path.join(dirPath, workingName + '.js');
source = fs.readFileSync(filePath, 'utf8');
options = {
'isSilent': isSilent,
'isTemplate': isTemplate,
@@ -79,14 +78,11 @@
*
* @private
* @constructor
* @param {String} [source=''] The source to minify.
* @param {Object} [options={}] The options object containing `onComplete`,
* `silent`, and `workingName`.
* @param {String} source The source to minify.
* @param {Object} options The options object.
*/
function Minify(source, options) {
source || (source = '');
options || (options = {});
// juggle arguments
if (typeof source != 'string') {
options = source || options;
source = options.source || '';
@@ -105,7 +101,7 @@
this.isSilent = !!options.isSilent;
this.isTemplate = !!options.isTemplate;
this.onComplete = options.onComplete || function() {};
this.workingName = options.workingName || 'temp';
this.workingName = options.workingName;
source = preprocess(source, options);
this.source = source;

View File

@@ -62,7 +62,11 @@
// was invoked directly (e.g. `node post-compile.js source.js`) and write to
// the same file
(function() {
var filePath = process.argv[2],
var options = process.argv;
if (options.length < 3) {
return;
}
var filePath = options[options.length - 1],
source = fs.readFileSync(filePath, 'utf8');
fs.writeFileSync(filePath, postprocess(source), 'utf8');

View File

@@ -245,11 +245,12 @@
/**
* Pre-process a given Lo-Dash `source`, preparing it for minification.
*
* @param {String} source The source to process.
* @param {String} [source=''] The source to process.
* @param {Object} [options={}] The options object.
* @returns {String} Returns the processed source.
*/
function preprocess(source, options) {
source || (source = '');
options || (options = {});
// remove unrecognized JSDoc tags so Closure Compiler won't complain
@@ -446,12 +447,17 @@
// was invoked directly (e.g. `node pre-compile.js source.js`) and write to
// the same file
(function() {
var options = process.argv,
filePath = options[options.length - 1],
var options = process.argv;
if (options.length < 3) {
return;
}
var filePath = options[options.length - 1],
isTemplate = options.indexOf('-t') > -1 || options.indexOf('--template') > -1,
source = fs.readFileSync(filePath, 'utf8');
fs.writeFileSync(filePath, preprocess(source, { 'isTemplate': isTemplate }), 'utf8');
fs.writeFileSync(filePath, preprocess(source, {
'isTemplate': isTemplate
}), 'utf8');
}());
}
}());