UNPKG

1.13 kBPlain TextView Raw
1#!/usr/bin/env node
2const npmPath = require('npm-path');
3const Abigail = require('./').Abigail;
4
5// update process.env
6npmPath();
7
8/*
9* abigail lifecycle (in serial)
10* initialized
11* parse
12* attach-plugins
13* (unless task) -> output logo && exit 1
14* launch
15* task-start (in parallel)
16* script-start
17* script-end
18* script-error
19* task-end
20* detach-plugins
21* exit
22* (all expection) -> output trace && exit 1
23*/
24
25const abigail = new Abigail().initialize(process.argv.slice(2));
26abigail.emit('initialized')
27.then(() => abigail.emit('parse'))
28.then(() => abigail.emit('attach-plugins'))
29.then(() => abigail.emit('launch'))
30.then(() => {
31 if (abigail.listeners('exit').length) {
32 return abigail.emit('detach-plugins')
33 .then(() => abigail.emit('exit'));
34 }
35
36 return process.once('SIGINT', () => {
37 try {
38 abigail.props.plugins.log.abort();
39 } catch (e) {
40 // ignore
41 }
42
43 abigail.emit('detach-plugins')
44 .then(() => abigail.emit('exit'));
45 });
46})
47.catch((reason) => {
48 console.trace(reason.message); // eslint-disable-line no-console
49 process.exit(1);
50});