Skip to content

Instantly share code, notes, and snippets.

@eyy
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eyy/b86d3eaa4696b8958473 to your computer and use it in GitHub Desktop.
Save eyy/b86d3eaa4696b8958473 to your computer and use it in GitHub Desktop.
Takser – node task runner
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