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