提交 bb25b46f 编写于 作者: J Joao Moreno

decouple execPath from parsedArgs

上级 3e601b5b
...@@ -273,7 +273,7 @@ function setupIPC(accessor: ServicesAccessor): TPromise<Server> { ...@@ -273,7 +273,7 @@ function setupIPC(accessor: ServicesAccessor): TPromise<Server> {
const services = new ServiceCollection(); const services = new ServiceCollection();
services.set(IEnvService, new SyncDescriptor(EnvService)); services.set(IEnvService, new SyncDescriptor(EnvService));
services.set(IEnvironmentService, new SyncDescriptor(EnvironmentService, parseArgs(process.argv))); services.set(IEnvironmentService, new SyncDescriptor(EnvironmentService, parseArgs(process.argv), process.execPath));
services.set(ILogService, new SyncDescriptor(MainLogService)); services.set(ILogService, new SyncDescriptor(MainLogService));
services.set(IWindowsService, new SyncDescriptor(WindowsManager)); services.set(IWindowsService, new SyncDescriptor(WindowsManager));
services.set(ILifecycleService, new SyncDescriptor(LifecycleService)); services.set(ILifecycleService, new SyncDescriptor(LifecycleService));
......
...@@ -10,7 +10,6 @@ import * as path from 'path'; ...@@ -10,7 +10,6 @@ import * as path from 'path';
import { parseArgs, ParsedArgs } from 'vs/code/node/argv'; import { parseArgs, ParsedArgs } from 'vs/code/node/argv';
import { TPromise } from 'vs/base/common/winjs.base'; import { TPromise } from 'vs/base/common/winjs.base';
import { sequence } from 'vs/base/common/async'; import { sequence } from 'vs/base/common/async';
import * as objects from 'vs/base/common/objects';
import { IPager } from 'vs/base/common/paging'; import { IPager } from 'vs/base/common/paging';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
...@@ -146,7 +145,7 @@ const eventPrefix = 'monacoworkbench'; ...@@ -146,7 +145,7 @@ const eventPrefix = 'monacoworkbench';
export function main(argv: ParsedArgs): TPromise<void> { export function main(argv: ParsedArgs): TPromise<void> {
const services = new ServiceCollection(); const services = new ServiceCollection();
services.set(IEnvironmentService, new SyncDescriptor(EnvironmentService, objects.assign(parseArgs(process.argv), { execPath: process.execPath }))); services.set(IEnvironmentService, new SyncDescriptor(EnvironmentService, parseArgs(process.argv), process.execPath));
const instantiationService: IInstantiationService = new InstantiationService(services); const instantiationService: IInstantiationService = new InstantiationService(services);
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
import * as fs from 'fs'; import * as fs from 'fs';
import * as platform from 'vs/base/common/platform'; import * as platform from 'vs/base/common/platform';
import product from 'vs/platform/product'; import product from 'vs/platform/product';
import * as objects from 'vs/base/common/objects';
import pkg from 'vs/platform/package'; import pkg from 'vs/platform/package';
import { serve, Server, connect } from 'vs/base/parts/ipc/node/ipc.net'; import { serve, Server, connect } from 'vs/base/parts/ipc/node/ipc.net';
import { TPromise } from 'vs/base/common/winjs.base'; import { TPromise } from 'vs/base/common/winjs.base';
...@@ -59,7 +58,7 @@ function main(server: Server): void { ...@@ -59,7 +58,7 @@ function main(server: Server): void {
const services = new ServiceCollection(); const services = new ServiceCollection();
services.set(IEventService, new SyncDescriptor(EventService)); services.set(IEventService, new SyncDescriptor(EventService));
services.set(IEnvironmentService, new SyncDescriptor(EnvironmentService, objects.assign(parseArgs(process.argv), { execPath: process.execPath }))); services.set(IEnvironmentService, new SyncDescriptor(EnvironmentService, parseArgs(process.argv), process.execPath));
services.set(IConfigurationService, new SyncDescriptor(NodeConfigurationService)); services.set(IConfigurationService, new SyncDescriptor(NodeConfigurationService));
services.set(IRequestService, new SyncDescriptor(RequestService)); services.set(IRequestService, new SyncDescriptor(RequestService));
......
...@@ -14,12 +14,6 @@ import { memoize } from 'vs/base/common/decorators'; ...@@ -14,12 +14,6 @@ import { memoize } from 'vs/base/common/decorators';
import pkg from 'vs/platform/package'; import pkg from 'vs/platform/package';
import product from 'vs/platform/product'; import product from 'vs/platform/product';
// TODO@Ben TODO@Joao this interface should be composed once the main => renderer
// communication is also fit for that
export interface IEnvironment extends ParsedArgs {
execPath: string;
}
function getUniqueUserId(): string { function getUniqueUserId(): string {
let username: string; let username: string;
if (process.platform === 'win32') { if (process.platform === 'win32') {
...@@ -62,7 +56,8 @@ export class EnvironmentService implements IEnvironmentService { ...@@ -62,7 +56,8 @@ export class EnvironmentService implements IEnvironmentService {
@memoize @memoize
get appRoot(): string { return path.dirname(URI.parse(require.toUrl('')).fsPath); } get appRoot(): string { return path.dirname(URI.parse(require.toUrl('')).fsPath); }
get execPath(): string { return this.args.execPath; }
get execPath(): string { return this._execPath; }
@memoize @memoize
get userHome(): string { return path.join(os.homedir(), product.dataFolderName); } get userHome(): string { return path.join(os.homedir(), product.dataFolderName); }
...@@ -101,7 +96,7 @@ export class EnvironmentService implements IEnvironmentService { ...@@ -101,7 +96,7 @@ export class EnvironmentService implements IEnvironmentService {
@memoize @memoize
get sharedIPCHandle(): string { return `${ IPCHandlePrefix }-${ pkg.version }-shared${ IPCHandleSuffix }`; } get sharedIPCHandle(): string { return `${ IPCHandlePrefix }-${ pkg.version }-shared${ IPCHandleSuffix }`; }
constructor(private args: IEnvironment) {} constructor(private args: ParsedArgs, private _execPath: string) {}
} }
export function parseExtensionHostPort(args: ParsedArgs, isBuild: boolean): { port: number; break: boolean; } { export function parseExtensionHostPort(args: ParsedArgs, isBuild: boolean): { port: number; break: boolean; } {
......
...@@ -14,7 +14,6 @@ import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry'; ...@@ -14,7 +14,6 @@ import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
import Storage = require('vs/workbench/common/storage'); import Storage = require('vs/workbench/common/storage');
import {EditorInputEvent, IEditorGroup} from 'vs/workbench/common/editor'; import {EditorInputEvent, IEditorGroup} from 'vs/workbench/common/editor';
import Event, {Emitter} from 'vs/base/common/event'; import Event, {Emitter} from 'vs/base/common/event';
import Objects = require('vs/base/common/objects');
import Severity from 'vs/base/common/severity'; import Severity from 'vs/base/common/severity';
import {IConfigurationService} from 'vs/platform/configuration/common/configuration'; import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
import {IContent, IStat} from 'vs/platform/configuration/common/configurationService'; import {IContent, IStat} from 'vs/platform/configuration/common/configurationService';
...@@ -49,7 +48,7 @@ export const TestWorkspace: IWorkspace = { ...@@ -49,7 +48,7 @@ export const TestWorkspace: IWorkspace = {
uid: new Date().getTime() uid: new Date().getTime()
}; };
export const TestEnvironmentService = new EnvironmentService(Objects.assign(parseArgs(process.argv), { execPath: process.execPath })); export const TestEnvironmentService = new EnvironmentService(parseArgs(process.argv), process.execPath);
export class TestContextService implements WorkspaceContextService.IWorkspaceContextService { export class TestContextService implements WorkspaceContextService.IWorkspaceContextService {
public _serviceBrand: any; public _serviceBrand: any;
......
...@@ -20,7 +20,8 @@ import {LegacyWorkspaceContextService} from 'vs/workbench/services/workspace/com ...@@ -20,7 +20,8 @@ import {LegacyWorkspaceContextService} from 'vs/workbench/services/workspace/com
import {IWorkspace} from 'vs/platform/workspace/common/workspace'; import {IWorkspace} from 'vs/platform/workspace/common/workspace';
import {ConfigurationService} from 'vs/workbench/services/configuration/node/configurationService'; import {ConfigurationService} from 'vs/workbench/services/configuration/node/configurationService';
import {IProcessEnvironment} from 'vs/code/electron-main/env'; import {IProcessEnvironment} from 'vs/code/electron-main/env';
import {EnvironmentService, IEnvironment} from 'vs/platform/environment/node/environmentService'; import {ParsedArgs} from 'vs/code/node/argv';
import {EnvironmentService} from 'vs/platform/environment/node/environmentService';
import path = require('path'); import path = require('path');
import fs = require('fs'); import fs = require('fs');
import gracefulFs = require('graceful-fs'); import gracefulFs = require('graceful-fs');
...@@ -46,7 +47,7 @@ export interface IPath { ...@@ -46,7 +47,7 @@ export interface IPath {
columnNumber?: number; columnNumber?: number;
} }
export interface IWindowConfiguration extends IEnvironment { export interface IWindowConfiguration extends ParsedArgs {
appRoot: string; appRoot: string;
execPath: string; execPath: string;
...@@ -127,9 +128,9 @@ function getWorkspace(workspacePath: string): IWorkspace { ...@@ -127,9 +128,9 @@ function getWorkspace(workspacePath: string): IWorkspace {
}; };
} }
function openWorkbench(environment: IEnvironment, workspace: IWorkspace, options: IOptions): winjs.TPromise<void> { function openWorkbench(environment: IWindowConfiguration, workspace: IWorkspace, options: IOptions): winjs.TPromise<void> {
const eventService = new EventService(); const eventService = new EventService();
const environmentService = new EnvironmentService(environment); const environmentService = new EnvironmentService(environment, environment.execPath);
const contextService = new LegacyWorkspaceContextService(eventService, workspace, options); const contextService = new LegacyWorkspaceContextService(eventService, workspace, options);
const configurationService = new ConfigurationService(contextService, eventService, environmentService); const configurationService = new ConfigurationService(contextService, eventService, environmentService);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册