1 | #!/usr/bin/env node
|
2 |
|
3 | "use strict";
|
4 | var path = require("path"),
|
5 | node = require("../package.json").engines.node,
|
6 | pathToLib = path.join(__dirname, "..", "lib"),
|
7 | pathToCommon = path.join(pathToLib, "common");
|
8 |
|
9 | require(path.join(pathToCommon, "verify-node-version")).verifyNodeVersion(node, "AppBuilder", ["^4.0.0", "^5.0.0"]);
|
10 |
|
11 | var pathToCliExecutable = path.join(pathToLib, "appbuilder-cli.js");
|
12 |
|
13 | var nodeArgs = require(path.join(pathToCommon, "scripts", "node-args")).getNodeArgs();
|
14 |
|
15 | if (nodeArgs.length) {
|
16 | // We need custom args for Node process, so pass them here.
|
17 | var childProcess = require("child_process");
|
18 | var args = process.argv;
|
19 |
|
20 | // Remove `node` and `appbuilder` from the arguments.
|
21 | args.shift();
|
22 | args.shift();
|
23 |
|
24 | args.unshift(pathToCliExecutable);
|
25 |
|
26 | args = nodeArgs.concat(args);
|
27 |
|
28 | var nodeProcess = childProcess.spawn(process.execPath, args, { stdio: "inherit" });
|
29 |
|
30 | nodeProcess.on("close", function(code) {
|
31 | // We need this handler so if command fails, we'll exit with same exit code as CLI.
|
32 | process.exit(code);
|
33 | });
|
34 | } else {
|
35 | require(pathToCliExecutable);
|
36 | }
|