UNPKG

1.06 kBJavaScriptView Raw
1/**
2 * React Starter Kit (https://www.reactstarterkit.com/)
3 *
4 * Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
5 *
6 * This source code is licensed under the MIT license found in the
7 * LICENSE.txt file in the root directory of this source tree.
8 */
9
10import 'babel-polyfill';
11import * as Tasks from './tasks';
12
13function format(time) {
14 return time.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, '$1');
15}
16
17export default function run(fn, options) {
18 const start = new Date();
19 console.log(`[${format(start)}] Starting '${fn.name}'...`); //eslint-disable-line
20 return fn(options).then(() => {
21 const end = new Date();
22 const time = end.getTime() - start.getTime();
23 console.log(`[${format(end)}] Finished '${fn.name}' after ${time} ms`); //eslint-disable-line
24 });
25}
26
27// if invoked via babel-node, execute the task
28if (process.argv.length > 2) {
29 delete require.cache[__filename];
30 const taskName = process.argv[2];
31 run(Tasks[taskName], process.argv[3]).catch(err => {
32 console.error(err.stack); // eslint-disable-line
33 });
34}