From 0f043bca567556605be4ab65bc2b826e884bed0a Mon Sep 17 00:00:00 2001 From: Roland Warmerdam Date: Fri, 22 Dec 2017 15:45:36 -0800 Subject: [PATCH] Revert "Remove unused task.js" This reverts commit 29455720956aea3dcc60a2fa01274d0ecf2c96b2. --- tools/task.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tools/task.js diff --git a/tools/task.js b/tools/task.js new file mode 100644 index 000000000..bd4ca5c23 --- /dev/null +++ b/tools/task.js @@ -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)