UNPKG

806 BPlain TextView Raw
1#!/usr/bin/env node
2'use strict';
3
4/* eslint-env node */
5
6/*
7 * Dependencies.
8 */
9
10var cli = require('../lib/cli');
11
12/*
13 * Methods.
14 */
15
16var stderr = process.stderr;
17var argv = process.argv;
18
19/*
20 * Constants.
21 */
22
23var exitStatus = 0;
24
25/**
26 * Failure handler.
27 *
28 * @param {Error?} exception
29 */
30function fail(exception, success) {
31 if (exception) {
32 stderr.write((exception.stack || exception) + '\n');
33 }
34
35 if (exception || !success) {
36 exitStatus = 1;
37 }
38}
39
40/*
41 * Set-up.
42 */
43
44var position = argv.indexOf('--');
45
46if (position !== -1) {
47 argv = argv.slice(0, position);
48}
49
50/*
51 * Process.
52 */
53
54cli(argv, fail);
55
56/*
57 * Exit.
58 */
59
60process.on('exit', function () {
61 /* eslint-disable no-process-exit */
62 process.exit(exitStatus);
63 /* eslint-enable no-process-exit */
64});