vague-date
Version:
A tiny JavaScript library that formats precise time differences as a vague/fuzzy date, e.g. 'yesterday', 'today' or 'next week'.
56 lines (46 loc) • 1.4 kB
JavaScript
/*jshint nomen:false */
/*globals require, console, complete, __dirname, process */
;
var exec = require('child_process').exec,
commands = {
minify: './node_modules/.bin/uglifyjs ./src/vagueDate.js --compress --mangle --output ./src/vagueDate.min.js',
test: './node_modules/.bin/mocha --ui tdd --reporter spec --colors ./test/vagueDate.js',
lint: './node_modules/.bin/jshint ./src/vagueDate.js --config config/jshint.json',
prepare: 'npm install'
};
desc('Minify the source code for deployment.');
task('minify', function () {
runCommand('minify', 'Minifying...');
}, {
async: true
});
desc('Run the unit tests.');
task('test', function () {
runCommand('test', 'Testing...');
}, {
async: true
});
desc('Lint the source code.');
task('lint', function () {
runCommand('lint', 'Linting...');
}, {
async: true
});
desc('Install dependencies.');
task('prepare', function () {
runCommand('prepare', 'Preparing the build environment...');
}, {
async: true
});
function runCommand (command, message) {
console.log(message);
exec(commands[command], { cwd: __dirname }, function (error, stdout, stderr) {
console.log(stdout);
console.log(stderr);
if (typeof error === 'object' && error !== null) {
console.log(error.message);
process.exit(1);
}
complete();
});
}