parseMainProcessArgv
This commit is contained in:
parent
62bfb65713
commit
bf3aff63b2
|
@ -10,7 +10,7 @@ import * as fs from 'original-fs';
|
|||
import { app, ipcMain as ipc } from 'electron';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import { parseArgs } from 'vs/code/node/argv';
|
||||
import { parseMainProcessArgv } from 'vs/code/node/argv';
|
||||
import { mkdirp } from 'vs/base/node/pfs';
|
||||
import { IProcessEnvironment, IEnvService, EnvService } from 'vs/code/electron-main/env';
|
||||
import { IWindowsService, WindowsManager } from 'vs/code/electron-main/windows';
|
||||
|
@ -272,8 +272,8 @@ function setupIPC(accessor: ServicesAccessor): TPromise<Server> {
|
|||
// TODO: isolate
|
||||
const services = new ServiceCollection();
|
||||
|
||||
services.set(IEnvironmentService, new SyncDescriptor(EnvironmentService, parseMainProcessArgv(process.argv), process.execPath));
|
||||
services.set(IEnvService, new SyncDescriptor(EnvService));
|
||||
services.set(IEnvironmentService, new SyncDescriptor(EnvironmentService, parseArgs(process.argv), process.execPath));
|
||||
services.set(ILogService, new SyncDescriptor(MainLogService));
|
||||
services.set(IWindowsService, new SyncDescriptor(WindowsManager));
|
||||
services.set(ILifecycleService, new SyncDescriptor(LifecycleService));
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
import * as os from 'os';
|
||||
import * as minimist from 'minimist';
|
||||
import { firstIndex } from 'vs/base/common/arrays';
|
||||
import { localize } from 'vs/nls';
|
||||
|
||||
export interface ParsedArgs extends minimist.ParsedArgs {
|
||||
|
@ -70,6 +71,27 @@ const options: minimist.Opts = {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Use this to parse raw code process.argv such as: `Electron . --verbose --wait`
|
||||
*/
|
||||
export function parseMainProcessArgv(processArgv: string[]): ParsedArgs {
|
||||
const [, ...args] = processArgv;
|
||||
|
||||
// If dev, remove the first non-option argument: it's the app location
|
||||
if (process.env['VSCODE_DEV']) {
|
||||
const index = firstIndex(args, a => !/^-/.test(a));
|
||||
|
||||
if (index > -1) {
|
||||
args.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return parseArgs(args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this to parse code arguments such as `--verbose --wait`
|
||||
*/
|
||||
export function parseArgs(args: string[]): ParsedArgs {
|
||||
return minimist(args, options) as ParsedArgs;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue