UNPKG

807 BJavaScriptView Raw
1#!/usr/bin/env node
2'use strict';
3
4const ver = process.versions.node;
5const majorVer = parseInt(ver.split('.')[0], 10);
6
7if (majorVer < 8) {
8 console.error('Node version ' + ver + ' is not supported, please use Node.js 8.0 or higher.');
9 process.exit(1);
10}
11
12let hasBundled = true
13
14try {
15 require.resolve('./index.bundled.js');
16} catch(err) {
17 // We don't have/need this on legacy builds and dev builds
18 // If an error happens here, throw it, that means no Node.js distribution exists at all.
19 hasBundled = false;
20}
21
22const cli = !hasBundled ? require('../') : require('./index.bundled.js');
23
24if (cli.autoRun) {
25 return;
26}
27
28const run = cli.run || cli.cli || cli.default;
29run(process.argv).catch(function (error) {
30 console.error(error.stack || error.message || error);
31 process.exitCode = 1;
32});