• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1namespace ts.server {
2    export type ActionSet = "action::set";
3    export type ActionInvalidate = "action::invalidate";
4    export type ActionPackageInstalled = "action::packageInstalled";
5    export type EventTypesRegistry = "event::typesRegistry";
6    export type EventBeginInstallTypes = "event::beginInstallTypes";
7    export type EventEndInstallTypes = "event::endInstallTypes";
8    export type EventInitializationFailed = "event::initializationFailed";
9    /* @internal */
10    export const ActionSet: ActionSet = "action::set";
11    /* @internal */
12    export const ActionInvalidate: ActionInvalidate = "action::invalidate";
13    /* @internal */
14    export const ActionPackageInstalled: ActionPackageInstalled = "action::packageInstalled";
15    /* @internal */
16    export const EventTypesRegistry: EventTypesRegistry = "event::typesRegistry";
17    /* @internal */
18    export const EventBeginInstallTypes: EventBeginInstallTypes = "event::beginInstallTypes";
19    /* @internal */
20    export const EventEndInstallTypes: EventEndInstallTypes = "event::endInstallTypes";
21    /* @internal */
22    export const EventInitializationFailed: EventInitializationFailed = "event::initializationFailed";
23
24    /* @internal */
25    export namespace Arguments {
26        export const GlobalCacheLocation = "--globalTypingsCacheLocation";
27        export const LogFile = "--logFile";
28        export const EnableTelemetry = "--enableTelemetry";
29        export const TypingSafeListLocation = "--typingSafeListLocation";
30        export const TypesMapLocation = "--typesMapLocation";
31        /**
32         * This argument specifies the location of the NPM executable.
33         * typingsInstaller will run the command with `${npmLocation} install ...`.
34         */
35        export const NpmLocation = "--npmLocation";
36        /**
37         * Flag indicating that the typings installer should try to validate the default npm location.
38         * If the default npm is not found when this flag is enabled, fallback to `npm install`
39         */
40        export const ValidateDefaultNpmLocation = "--validateDefaultNpmLocation";
41    }
42
43    /* @internal */
44    export function hasArgument(argumentName: string) {
45        return sys.args.indexOf(argumentName) >= 0;
46    }
47
48    /* @internal */
49    export function findArgument(argumentName: string): string | undefined {
50        const index = sys.args.indexOf(argumentName);
51        return index >= 0 && index < sys.args.length - 1
52            ? sys.args[index + 1]
53            : undefined;
54    }
55
56    /* @internal */
57    export function nowString() {
58        // E.g. "12:34:56.789"
59        const d = new Date();
60        return `${padLeft(d.getHours().toString(), 2, "0")}:${padLeft(d.getMinutes().toString(), 2, "0")}:${padLeft(d.getSeconds().toString(), 2, "0")}.${padLeft(d.getMilliseconds().toString(), 3, "0")}`;
61    }
62}
63