Skip to content

Commit

Permalink
Revert "Remove unused task.js"
Browse files Browse the repository at this point in the history
This reverts commit 2945572.
  • Loading branch information
Rowno committed Dec 22, 2017
1 parent 2945572 commit 0f043bc
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tools/task.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* eslint-env node */
// https://medium.com/@tarkus/build-automation-with-vanilla-javascript-74639ec98bad
function run(task, action, ...args) {
const command = process.argv[2]
const taskName =
command && !command.startsWith('-') ? `${task} ${command}` : task
const start = new Date()
process.stdout.write(`Starting '${taskName}'...\n`)
return Promise.resolve()
.then(() => action(...args))
.then(
() => {
process.stdout.write(
`Finished '${taskName}' after ${new Date().getTime() -
start.getTime()}ms\n`
)
},
err => process.stderr.write(`${err.stack}\n`)
)
}

process.nextTick(() => require.main.exports())
module.exports = (task, action) => run.bind(undefined, task, action)

0 comments on commit 0f043bc

Please sign in to comment.