pdf.js/external/shelljs/make.js

49 lines
1009 B
JavaScript
Raw Normal View History

2012-03-04 04:01:31 +09:00
require('./global');
2013-03-08 01:32:16 +09:00
config.fatal = true;
2012-03-04 04:01:31 +09:00
global.target = {};
// This ensures we only execute the script targets after the entire script has
// been evaluated
var args = process.argv.slice(2);
setTimeout(function() {
2013-03-08 01:32:16 +09:00
var t;
2012-03-04 04:01:31 +09:00
if (args.length === 1 && args[0] === '--help') {
console.log('Available targets:');
for (t in target)
console.log(' ' + t);
return;
}
// Wrap targets to prevent duplicate execution
for (t in target) {
(function(t, oldTarget){
// Wrap it
target[t] = function(force) {
if (oldTarget.done && !force)
return;
oldTarget.done = true;
2012-03-29 07:03:31 +09:00
return oldTarget.apply(oldTarget, arguments);
2013-03-08 01:32:16 +09:00
};
2012-03-04 04:01:31 +09:00
})(t, target[t]);
}
// Execute desired targets
if (args.length > 0) {
args.forEach(function(arg) {
2013-03-08 01:32:16 +09:00
if (arg in target)
2012-03-04 04:01:31 +09:00
target[arg]();
else {
console.log('no such target: ' + arg);
exit(1);
}
});
} else if ('all' in target) {
target.all();
}
}, 0);