當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript argv.parseArgs函數代碼示例

本文整理匯總了TypeScript中vs/code/node/argv.parseArgs函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript parseArgs函數的具體用法?TypeScript parseArgs怎麽用?TypeScript parseArgs使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了parseArgs函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: main

export function main(args: string[]) {
	const argv = parseArgs(args);

	if (argv.help) {
		console.log(helpMessage);
	} else if (argv.version) {
		console.log(pkg.version);
	} else {
		const env = assign({}, process.env, {
			// this will signal Code that it was spawned from this module
			'VSCODE_CLI': '1',
			'ELECTRON_NO_ATTACH_CONSOLE': '1'
		});
		delete env['ATOM_SHELL_INTERNAL_RUN_AS_NODE'];

		const child = spawn(process.execPath, args, {
			detached: true,
			stdio: 'ignore',
			env
		});

		if (argv.wait) {
			child.on('exit', process.exit);
			return;
		}
	}

	process.exit(0);
}
開發者ID:Elflyy,項目名稱:vscode,代碼行數:29,代碼來源:cli.ts

示例2: main

export function main(args: string[]): TPromise<void> {
	const argv = parseArgs(args);

	if (argv.help) {
		console.log(helpMessage);
	} else if (argv.version) {
		console.log(pkg.version);
	} else if (shouldSpawnCliProcess(argv)) {
		const mainCli = new TPromise<IMainCli>(c => require(['vs/code/node/cliProcessMain'], c));
		return mainCli.then(cli => cli.main(argv));
	} else {
		const env = assign({}, process.env, {
			// this will signal Code that it was spawned from this module
			'VSCODE_CLI': '1',
			'ELECTRON_NO_ATTACH_CONSOLE': '1'
		});
		delete env['ATOM_SHELL_INTERNAL_RUN_AS_NODE'];

		const child = spawn(process.execPath, args, {
			detached: true,
			stdio: 'ignore',
			env
		});

		if (argv.wait) {
			return new TPromise<void>(c => child.once('exit', ()=> c(null)));
		}
	}

	return TPromise.as(null);
}
開發者ID:13572293130,項目名稱:vscode,代碼行數:31,代碼來源:cli.ts

示例3: constructor

	constructor() {
		this._appRoot = path.dirname(URI.parse(require.toUrl('')).fsPath);
		this._currentWorkingDirectory = process.env['VSCODE_CWD'] || process.cwd();
		this._appHome = app.getPath('userData');
		this._appSettingsHome = path.join(this._appHome, 'User');
		this._appSettingsPath = path.join(this._appSettingsHome, 'settings.json');
		this._appKeybindingsPath = path.join(this._appSettingsHome, 'keybindings.json');

		// Remove the Electron executable
		let [, ...args] = process.argv;

		// If dev, remove the first non-option argument: it's the app location
		if (!this.isBuilt) {
			const index = arrays.firstIndex(args, a => !/^-/.test(a));

			if (index > -1) {
				args.splice(index, 1);
			}
		}

		// Finally, prepend any extra arguments from the 'argv' file
		if (fs.existsSync(path.join(this._appRoot, 'argv'))) {
			const extraargs: string[] = JSON.parse(fs.readFileSync(path.join(this._appRoot, 'argv'), 'utf8'));
			args = [...extraargs, ...args];
		}

		const argv = parseArgs(args);
		const paths = parsePathArguments(this._currentWorkingDirectory, argv._, argv.goto);

		this._cliArgs = Object.freeze({
			_: [],
			paths,
			performance: argv.performance,
			verbose: argv.verbose,
			debugPluginHost: argv.debugPluginHost,
			debugBrkPluginHost: argv.debugBrkPluginHost,
			logExtensionHostCommunication: argv.logExtensionHostCommunication,
			'new-window': argv['new-window'],
			'reuse-window': argv['reuse-window'],
			goto: argv.goto,
			diff: argv.diff && paths.length === 2,
			extensionHomePath: normalizePath(argv.extensionHomePath),
			extensionDevelopmentPath: normalizePath(argv.extensionDevelopmentPath),
			extensionTestsPath: normalizePath(argv.extensionTestsPath),
			'disable-extensions': argv['disable-extensions'],
			locale: argv.locale,
			wait: argv.wait
		});

		this._isTestingFromCli = this.cliArgs.extensionTestsPath && !this.cliArgs.debugBrkPluginHost;
		this._userHome = path.join(os.homedir(), product.dataFolderName);
		this._userExtensionsHome = this.cliArgs.extensionHomePath || path.join(this._userHome, 'extensions');

		const prefix = this.getIPCHandleBaseName();
		const suffix = process.platform === 'win32' ? '-sock' : '.sock';

		this._mainIPCHandle = `${ prefix }-${ pkg.version }${ suffix }`;
		this._sharedIPCHandle = `${ prefix }-${ pkg.version }-shared${ suffix }`;
	}
開發者ID:rajkumar42,項目名稱:vscode,代碼行數:59,代碼來源:env.ts

示例4: main

function main(server: Server): void {
	const services = new ServiceCollection();

	services.set(IEventService, new SyncDescriptor(EventService));
	services.set(IEnvironmentService, new SyncDescriptor(EnvironmentService, parseArgs(process.argv), process.execPath));
	services.set(IConfigurationService, new SyncDescriptor(ConfigurationService));
	services.set(IRequestService, new SyncDescriptor(RequestService));

	const instantiationService = new InstantiationService(services);

	instantiationService.invokeFunction(accessor => {
		const appenders: AppInsightsAppender[] = [];

		if (product.aiConfig && product.aiConfig.key) {
			appenders.push(new AppInsightsAppender(eventPrefix, null, product.aiConfig.key));
		}

		if (product.aiConfig && product.aiConfig.asimovKey) {
			appenders.push(new AppInsightsAppender(eventPrefix, null, product.aiConfig.asimovKey));
		}

		// It is important to dispose the AI adapter properly because
		// only then they flush remaining data.
		process.once('exit', () => appenders.forEach(a => a.dispose()));

		const appender = combinedAppender(...appenders);
		server.registerChannel('telemetryAppender', new TelemetryAppenderChannel(appender));

		const services = new ServiceCollection();
		const { appRoot, extensionsPath, extensionDevelopmentPath, isBuilt } = accessor.get(IEnvironmentService);

		if (isBuilt && !extensionDevelopmentPath && product.enableTelemetry) {
			const config: ITelemetryServiceConfig = {
				appender,
				commonProperties: resolveCommonProperties(product.commit, pkg.version),
				piiPaths: [appRoot, extensionsPath]
			};

			services.set(ITelemetryService, new SyncDescriptor(TelemetryService, config));
		} else {
			services.set(ITelemetryService, NullTelemetryService);
		}

		services.set(IExtensionManagementService, new SyncDescriptor(ExtensionManagementService));
		services.set(IExtensionGalleryService, new SyncDescriptor(ExtensionGalleryService));

		const instantiationService2 = instantiationService.createChild(services);

		instantiationService2.invokeFunction(accessor => {
			const extensionManagementService = accessor.get(IExtensionManagementService);
			const channel = new ExtensionManagementChannel(extensionManagementService);
			server.registerChannel('extensions', channel);

			// eventually clean up old extensions
			setTimeout(() => (extensionManagementService as ExtensionManagementService).removeDeprecatedExtensions(), 100);
		});
	});
}
開發者ID:eklavyamirani,項目名稱:vscode,代碼行數:58,代碼來源:sharedProcessMain.ts

示例5: constructor

	constructor() {
		const argv = parseArgs(process.argv);

		this._appRoot = path.dirname(URI.parse(require.toUrl('')).fsPath);
		this._userDataPath = paths.getUserDataPath(process.platform, pkg.name, process.argv);

		this._userHome = path.join(os.homedir(), product.dataFolderName);
		this._extensionsPath = argv.extensionHomePath || path.join(this._userHome, 'extensions');
		this._extensionsPath = path.normalize(this._extensionsPath);

		this._extensionDevelopmentPath = argv.extensionDevelopmentPath;
	}
開發者ID:1Hgm,項目名稱:vscode,代碼行數:12,代碼來源:environmentService.ts

示例6: constructor

	constructor() {
		this._appRoot = path.dirname(URI.parse(require.toUrl('')).fsPath);
		this._currentWorkingDirectory = process.env['VSCODE_CWD'] || process.cwd();
		this._appHome = app.getPath('userData');
		this._appSettingsHome = path.join(this._appHome, 'User');
		this._appSettingsPath = path.join(this._appSettingsHome, 'settings.json');
		this._appKeybindingsPath = path.join(this._appSettingsHome, 'keybindings.json');

		// Remove the Electron executable
		let [, ...args] = process.argv;

		// If dev, remove the first non-option argument: it's the app location
		if (!this.isBuilt) {
			const index = arrays.firstIndex(args, a => !/^-/.test(a));

			if (index > -1) {
				args.splice(index, 1);
			}
		}

		const argv = parseArgs(args);
		const paths = parsePathArguments(this._currentWorkingDirectory, argv._, argv.goto);

		this._cliArgs = Object.freeze({
			_: [],
			paths,
			performance: argv.performance,
			verbose: argv.verbose,
			debugPluginHost: argv.debugPluginHost,
			debugBrkPluginHost: argv.debugBrkPluginHost,
			logExtensionHostCommunication: argv.logExtensionHostCommunication,
			'new-window': argv['new-window'],
			'reuse-window': argv['reuse-window'],
			goto: argv.goto,
			diff: argv.diff && paths.length === 2,
			extensionHomePath: normalizePath(argv.extensionHomePath),
			extensionDevelopmentPath: normalizePath(argv.extensionDevelopmentPath),
			extensionTestsPath: normalizePath(argv.extensionTestsPath),
			'disable-extensions': argv['disable-extensions'],
			locale: argv.locale,
			wait: argv.wait
		});

		this._userHome = path.join(os.homedir(), product.dataFolderName);
		this._userExtensionsHome = this.cliArgs.extensionHomePath || path.join(this._userHome, 'extensions');
	}
開發者ID:douglaseccker,項目名稱:vscode,代碼行數:46,代碼來源:env.ts

示例7: main

export function main(args: string[]): TPromise<void> {
	const argv = parseArgs(args);

	if (argv.help) {
		console.log(helpMessage);
	} else if (argv.version) {
		console.log(pkg.version);
	} else if (shouldSpawnCliProcess(argv)) {
		const mainCli = new TPromise<IMainCli>(c => require(['vs/code/node/cliProcessMain'], c));
		return mainCli.then(cli => cli.main(argv));
	} else {
		const env = assign({}, process.env, {
			// this will signal Code that it was spawned from this module
			'VSCODE_CLI': '1',
			'ELECTRON_NO_ATTACH_CONSOLE': '1'
		});
		delete env['ATOM_SHELL_INTERNAL_RUN_AS_NODE'];

		let options = {
			detacted: true,
			env,
		};
		if (!argv.verbose) {
			options['stdio'] = 'ignore';
		}

		const child = spawn(process.execPath, args, options);

		if (argv.verbose) {
			child.stdout.on('data', (data) => console.log(data.toString('utf8').trim()));
			child.stderr.on('data', (data) => console.log(data.toString('utf8').trim()));
		}

		if (argv.wait || argv.verbose) {
			return new TPromise<void>(c => child.once('exit', () => c(null)));
		}
	}

	return TPromise.as(null);
}
開發者ID:ckapilla,項目名稱:vscode,代碼行數:40,代碼來源:cli.ts

示例8: constructor

	constructor() {
		this._appRoot = path.dirname(URI.parse(require.toUrl('')).fsPath);
		this._currentWorkingDirectory = process.env['VSCODE_CWD'] || process.cwd();
		this._appHome = app.getPath('userData');
		this._appSettingsHome = path.join(this._appHome, 'User');
		this._appSettingsPath = path.join(this._appSettingsHome, 'settings.json');
		this._appKeybindingsPath = path.join(this._appSettingsHome, 'keybindings.json');

		// Remove the Electron executable
		let [, ...args] = process.argv;

		// If dev, remove the first non-option argument: it's the app location
		if (!this.isBuilt) {
			const index = arrays.firstIndex(args, a => !/^-/.test(a));

			if (index > -1) {
				args.splice(index, 1);
			}
		}

		// Finally, prepend any extra arguments from the 'argv' file
		if (fs.existsSync(path.join(this._appRoot, 'argv'))) {
			const extraargs: string[] = JSON.parse(fs.readFileSync(path.join(this._appRoot, 'argv'), 'utf8'));
			args = [...extraargs, ...args];
		}

		const argv = parseArgs(args);

		const debugBrkExtensionHostPort = getNumericValue(argv.debugBrkPluginHost, 5870);
		const debugExtensionHostPort = getNumericValue(argv.debugPluginHost, 5870, this.isBuilt ? void 0 : 5870);
		const pathArguments = parsePathArguments(this._currentWorkingDirectory, argv._, argv.goto);
		const timestamp = parseInt(argv.timestamp);
		const debugBrkFileWatcherPort = getNumericValue(argv.debugBrkFileWatcherPort, void 0);

		this._cliArgs = Object.freeze({
			pathArguments: pathArguments,
			programStart: types.isNumber(timestamp) ? timestamp : 0,
			enablePerformance: argv.performance,
			verboseLogging: argv.verbose,
			debugExtensionHostPort: debugBrkExtensionHostPort || debugExtensionHostPort,
			debugBrkExtensionHost: !!debugBrkExtensionHostPort,
			logExtensionHostCommunication: argv.logExtensionHostCommunication,
			debugBrkFileWatcherPort: debugBrkFileWatcherPort,
			openNewWindow: argv['new-window'],
			openInSameWindow: argv['reuse-window'],
			gotoLineMode: argv.goto,
			diffMode: argv.diff && pathArguments.length === 2,
			extensionsHomePath: normalizePath(argv.extensionHomePath),
			extensionDevelopmentPath: normalizePath(argv.extensionDevelopmentPath),
			extensionTestsPath: normalizePath(argv.extensionTestsPath),
			disableExtensions: argv['disable-extensions'],
			locale: argv.locale,
			waitForWindowClose: argv.wait
		});

		this._isTestingFromCli = this.cliArgs.extensionTestsPath && !this.cliArgs.debugBrkExtensionHost;
		this._userHome = path.join(os.homedir(), product.dataFolderName);
		this._userExtensionsHome = this.cliArgs.extensionsHomePath || path.join(this._userHome, 'extensions');
		this._mainIPCHandle = this.getMainIPCHandle();
		this._sharedIPCHandle = this.getSharedIPCHandle();
	}
開發者ID:Ayush-Mahajan,項目名稱:vscode,代碼行數:61,代碼來源:env.ts

示例9: parseExtensionHostPort

		const parse = a => parseExtensionHostPort(parseArgs(a), false);
開發者ID:rajkumar42,項目名稱:vscode,代碼行數:1,代碼來源:environmentService.test.ts


注:本文中的vs/code/node/argv.parseArgs函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。