Last active
January 4, 2016 18:49
-
-
Save BaseCase/8663131 to your computer and use it in GitHub Desktop.
`chmod +x` then just `./build.js compress` and you're off
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/node | |
var minify = require('uglify-js').minify; | |
var fs = require('fs'); | |
var tasks = { | |
//tasks go here. here's an example Uglify: | |
compress: function() { | |
var minified = minify('input.js'); | |
fs.writeFile('example.js', minified.code, function(err) { | |
if (err) throw err; | |
console.log('Minified example.js'); | |
runNextTask(); //as long as the task calls runNextTask() at the end, chaining works | |
}); | |
}, | |
}; | |
var commands = process.argv.slice(2); | |
function runNextTask() { | |
var task = commands.shift(); | |
if (typeof(task) !== 'undefined') { | |
tasks[task](); | |
} | |
} | |
runNextTask(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment