-
-
Notifications
You must be signed in to change notification settings - Fork 201
Expand file tree
/
Copy pathnativescript-cli.ts
More file actions
53 lines (43 loc) · 1.95 KB
/
nativescript-cli.ts
File metadata and controls
53 lines (43 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
require("./bootstrap");
import * as shelljs from "shelljs";
shelljs.config.silent = true;
shelljs.config.fatal = true;
import { installUncaughtExceptionListener } from "./common/errors";
import { settlePromises } from "./common/helpers";
installUncaughtExceptionListener(process.exit.bind(process, ErrorCodes.UNCAUGHT));
const logger: ILogger = $injector.resolve("logger");
const originalProcessOn = process.on;
process.on = (event: string, listener: any): any => {
if (event === "SIGINT") {
logger.trace(`Trying to handle SIGINT event. CLI overrides this behavior and does not allow handling SIGINT as this causes issues with Ctrl + C in terminal.`);
const msg = "The stackTrace of the location trying to handle SIGINT is:";
const stackTrace = new Error(msg).stack || '';
logger.trace(stackTrace.replace(`Error: ${msg}`, msg));
} else {
return originalProcessOn.apply(process, [event, listener]);
}
};
/* tslint:disable:no-floating-promises */
(async () => {
const config: Config.IConfig = $injector.resolve("$config");
const err: IErrors = $injector.resolve("$errors");
err.printCallStack = config.DEBUG;
const $initializeService = $injector.resolve<IInitializeService>("initializeService");
await $initializeService.initialize();
const extensibilityService: IExtensibilityService = $injector.resolve("extensibilityService");
try {
await settlePromises<IExtensionData>(extensibilityService.loadExtensions());
} catch (err) {
logger.trace("Unable to load extensions. Error is: ", err);
}
const commandDispatcher: ICommandDispatcher = $injector.resolve("commandDispatcher");
const messages: IMessagesService = $injector.resolve("$messagesService");
messages.pathsToMessageJsonFiles = [/* Place client-specific json message file paths here */];
if (process.argv[2] === "completion") {
await commandDispatcher.completeCommand();
} else {
await commandDispatcher.dispatchCommand();
}
$injector.dispose();
})();
/* tslint:enable:no-floating-promises */