Last active
August 29, 2015 14:26
-
-
Save eyy/b86d3eaa4696b8958473 to your computer and use it in GitHub Desktop.
Takser – node task runner
This file contains hidden or 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
function first () { | |
console.log(1) | |
} | |
function second () { | |
console.log(2) | |
} | |
function three (val) { | |
console.log('wait...') | |
setTimeout(function () { | |
console.log(val) | |
}, 500) | |
} | |
module.exports = { | |
first: first, | |
second: second, | |
three: three | |
} | |
if (!module.parent) | |
tasker(module.exports) | |
function tasker (tasks) { | |
process.argv.slice(2).forEach(function (val) { | |
val = val.split('=') | |
if (tasks[val[0]]) | |
tasks[val[0]](val[1]) | |
else | |
console.error('No task as ' + val[0]) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment