From a7da0430da113e0f710c6d59c3993badd7bddd6b Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Wed, 17 Aug 2016 13:38:48 +0200 Subject: [PATCH] let execPath be a property of IEnvironmentService --- src/vs/code/electron-main/window.ts | 1 + src/vs/code/electron-main/windows.ts | 1 + .../environment/common/environment.ts | 1 + .../environment/node/environmentService.ts | 8 ++++++- src/vs/test/utils/servicesTestUtils.ts | 7 +++--- src/vs/workbench/electron-browser/main.ts | 7 +++--- .../debug/electron-browser/debugService.ts | 2 +- .../debugConfigurationManager.ts | 6 +++-- .../electron-browser/electronGitService.ts | 13 +++++------ .../configVariables.ts | 12 ++++++++-- .../systemVariables.ts | 6 ++--- .../configVariables.test.ts | 13 ++++++----- .../systemVariables.test.ts | 11 +++++----- .../electron-browser/task.contribution.ts | 22 +++++++++++-------- .../processRunnerConfiguration.ts | 0 .../processRunnerDetector.ts | 2 +- .../processRunnerSystem.ts | 0 .../configuration.test.ts | 2 +- 18 files changed, 68 insertions(+), 46 deletions(-) rename src/vs/workbench/parts/debug/{electron-browser => node}/debugConfigurationManager.ts (98%) rename src/vs/workbench/parts/lib/{electron-browser => node}/configVariables.ts (74%) rename src/vs/workbench/parts/lib/{electron-browser => node}/systemVariables.ts (93%) rename src/vs/workbench/parts/lib/test/{electron-browser => node}/configVariables.test.ts (87%) rename src/vs/workbench/parts/lib/test/{electron-browser => node}/systemVariables.test.ts (83%) rename src/vs/workbench/parts/tasks/{electron-browser => node}/processRunnerConfiguration.ts (100%) rename src/vs/workbench/parts/tasks/{electron-browser => node}/processRunnerDetector.ts (99%) rename src/vs/workbench/parts/tasks/{electron-browser => node}/processRunnerSystem.ts (100%) rename src/vs/workbench/parts/tasks/test/{electron-browser => node}/configuration.test.ts (99%) diff --git a/src/vs/code/electron-main/window.ts b/src/vs/code/electron-main/window.ts index b2948232b95..7b64782330c 100644 --- a/src/vs/code/electron-main/window.ts +++ b/src/vs/code/electron-main/window.ts @@ -105,6 +105,7 @@ export interface IWindowConfiguration extends ICommandLineArguments { // Used to send the main process environment over to the renderer appRoot: string; + execPath: string; userEnv: IProcessEnvironment; } diff --git a/src/vs/code/electron-main/windows.ts b/src/vs/code/electron-main/windows.ts index 861e188f6a6..b9973e8ec1c 100644 --- a/src/vs/code/electron-main/windows.ts +++ b/src/vs/code/electron-main/windows.ts @@ -732,6 +732,7 @@ export class WindowsManager implements IWindowsService { configuration.filesToDiff = filesToDiff; configuration.extensionsToInstall = extensionsToInstall; configuration.appRoot = this.envService.appRoot; + configuration.execPath = process.execPath; configuration.appSettingsHome = this.envService.appSettingsHome; configuration.userExtensionsHome = this.envService.userExtensionsHome; configuration.userEnv = userEnv; diff --git a/src/vs/platform/environment/common/environment.ts b/src/vs/platform/environment/common/environment.ts index 8d58bd909db..9ab6e10c1e8 100644 --- a/src/vs/platform/environment/common/environment.ts +++ b/src/vs/platform/environment/common/environment.ts @@ -10,6 +10,7 @@ export const IEnvironmentService = createDecorator('environ export interface IEnvironmentService { _serviceBrand: any; + execPath: string; appRoot: string; userHome: string; diff --git a/src/vs/platform/environment/node/environmentService.ts b/src/vs/platform/environment/node/environmentService.ts index 869baa2bde3..9e5c098e1ba 100644 --- a/src/vs/platform/environment/node/environmentService.ts +++ b/src/vs/platform/environment/node/environmentService.ts @@ -11,6 +11,10 @@ import * as path from 'path'; import {ParsedArgs} from 'vs/code/node/argv'; import URI from 'vs/base/common/uri'; +export interface IEnvironment extends ParsedArgs { + execPath: string; +} + export class EnvironmentService implements IEnvironmentService { _serviceBrand: any; @@ -18,6 +22,8 @@ export class EnvironmentService implements IEnvironmentService { private _appRoot: string; get appRoot(): string { return this._appRoot; } + get execPath(): string { return this.args.execPath; } + private _userHome: string; get userHome(): string { return this._userHome; } @@ -52,7 +58,7 @@ export class EnvironmentService implements IEnvironmentService { private _debugBrkFileWatcherPort: number; get debugBrkFileWatcherPort(): number { return this._debugBrkFileWatcherPort; } - constructor(private args: ParsedArgs) { + constructor(private args: IEnvironment) { this._appRoot = path.dirname(URI.parse(require.toUrl('')).fsPath); this._userDataPath = args['user-data-dir'] || paths.getDefaultUserDataPath(process.platform); diff --git a/src/vs/test/utils/servicesTestUtils.ts b/src/vs/test/utils/servicesTestUtils.ts index a475aa1a2af..c6c879d7ad9 100644 --- a/src/vs/test/utils/servicesTestUtils.ts +++ b/src/vs/test/utils/servicesTestUtils.ts @@ -10,13 +10,12 @@ import { TestInstantiationService } from 'vs/test/utils/instantiationTestUtils'; import EventEmitter = require('vs/base/common/eventEmitter'); import Paths = require('vs/base/common/paths'); import URI from 'vs/base/common/uri'; -import {NullTelemetryService, ITelemetryService} from 'vs/platform/telemetry/common/telemetry'; +import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry'; import Storage = require('vs/workbench/common/storage'); import {EditorInputEvent, IEditorGroup} from 'vs/workbench/common/editor'; import Event, {Emitter} from 'vs/base/common/event'; -import Types = require('vs/base/common/types'); +import Objects = require('vs/base/common/objects'); import Severity from 'vs/base/common/severity'; -import http = require('vs/base/common/http'); import {IConfigurationService} from 'vs/platform/configuration/common/configuration'; import {IContent, IStat} from 'vs/platform/configuration/common/configurationService'; import {IStorageService, StorageScope} from 'vs/platform/storage/common/storage'; @@ -56,7 +55,7 @@ export const TestConfiguration: IConfiguration = { env: Object.create(null) }; -export const TestEnvironmentService = new EnvironmentService(parseArgs(process.argv)); +export const TestEnvironmentService = new EnvironmentService(Objects.assign(parseArgs(process.argv), { execPath: process.execPath })); export class TestContextService implements WorkspaceContextService.IWorkspaceContextService { public _serviceBrand: any; diff --git a/src/vs/workbench/electron-browser/main.ts b/src/vs/workbench/electron-browser/main.ts index 021d02ce155..6bea2edee72 100644 --- a/src/vs/workbench/electron-browser/main.ts +++ b/src/vs/workbench/electron-browser/main.ts @@ -16,11 +16,10 @@ import uri from 'vs/base/common/uri'; import strings = require('vs/base/common/strings'); import {IResourceInput} from 'vs/platform/editor/common/editor'; import {EventService} from 'vs/platform/event/common/eventService'; -import {ParsedArgs} from 'vs/code/node/argv'; import {WorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService'; import {IWorkspace} from 'vs/platform/workspace/common/workspace'; import {ConfigurationService} from 'vs/workbench/services/configuration/node/configurationService'; -import {EnvironmentService} from 'vs/platform/environment/node/environmentService'; +import {EnvironmentService, IEnvironment} from 'vs/platform/environment/node/environmentService'; import path = require('path'); import fs = require('fs'); import gracefulFs = require('graceful-fs'); @@ -46,7 +45,7 @@ export interface IPath { columnNumber?: number; } -export interface IConfiguration extends ParsedArgs { +export interface IConfiguration extends IEnvironment { workspacePath?: string; filesToOpen?: IPath[]; filesToCreate?: IPath[]; @@ -128,7 +127,7 @@ function getWorkspace(workspacePath: string): IWorkspace { }; } -function openWorkbench(environment: ParsedArgs, workspace: IWorkspace, configuration: IConfiguration, options: IOptions): winjs.TPromise { +function openWorkbench(environment: IEnvironment, workspace: IWorkspace, configuration: IConfiguration, options: IOptions): winjs.TPromise { const eventService = new EventService(); const environmentService = new EnvironmentService(environment); const contextService = new WorkspaceContextService(eventService, workspace, configuration, options); diff --git a/src/vs/workbench/parts/debug/electron-browser/debugService.ts b/src/vs/workbench/parts/debug/electron-browser/debugService.ts index 8901ca8ba55..6e1dd81fc0e 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugService.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugService.ts @@ -37,7 +37,7 @@ import model = require('vs/workbench/parts/debug/common/debugModel'); import {DebugStringEditorInput} from 'vs/workbench/parts/debug/browser/debugEditorInputs'; import viewmodel = require('vs/workbench/parts/debug/common/debugViewModel'); import debugactions = require('vs/workbench/parts/debug/browser/debugActions'); -import {ConfigurationManager} from 'vs/workbench/parts/debug/electron-browser/debugConfigurationManager'; +import {ConfigurationManager} from 'vs/workbench/parts/debug/node/debugConfigurationManager'; import {Source} from 'vs/workbench/parts/debug/common/debugSource'; import {ITaskService, TaskEvent, TaskType, TaskServiceEvents, ITaskSummary} from 'vs/workbench/parts/tasks/common/taskService'; import {TaskError, TaskErrors} from 'vs/workbench/parts/tasks/common/taskSystem'; diff --git a/src/vs/workbench/parts/debug/electron-browser/debugConfigurationManager.ts b/src/vs/workbench/parts/debug/node/debugConfigurationManager.ts similarity index 98% rename from src/vs/workbench/parts/debug/electron-browser/debugConfigurationManager.ts rename to src/vs/workbench/parts/debug/node/debugConfigurationManager.ts index 82e7a45da48..29716f84c26 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugConfigurationManager.ts +++ b/src/vs/workbench/parts/debug/node/debugConfigurationManager.ts @@ -29,8 +29,9 @@ import {Adapter} from 'vs/workbench/parts/debug/node/debugAdapter'; import {IWorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService'; import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService'; import {IQuickOpenService} from 'vs/workbench/services/quickopen/common/quickOpenService'; -import {ConfigVariables} from 'vs/workbench/parts/lib/electron-browser/configVariables'; +import {ConfigVariables} from 'vs/workbench/parts/lib/node/configVariables'; import {ISystemVariables} from 'vs/base/common/parsers'; +import {IEnvironmentService} from 'vs/platform/environment/common/environment'; // debuggers extension point export const debuggersExtPoint = extensionsRegistry.ExtensionsRegistry.registerExtensionPoint('debuggers', { @@ -183,10 +184,11 @@ export class ConfigurationManager implements debug.IConfigurationManager { @ITelemetryService private telemetryService: ITelemetryService, @IWorkbenchEditorService private editorService: IWorkbenchEditorService, @IConfigurationService private configurationService: IConfigurationService, + @IEnvironmentService private environmentService: IEnvironmentService, @IQuickOpenService private quickOpenService: IQuickOpenService, @ICommandService private commandService: ICommandService ) { - this.systemVariables = this.contextService.getWorkspace() ? new ConfigVariables(this.configurationService, this.editorService, this.contextService) : null; + this.systemVariables = this.contextService.getWorkspace() ? new ConfigVariables(this.configurationService, this.editorService, this.contextService, this.environmentService) : null; this._onDidConfigurationChange = new Emitter(); this.setConfiguration(configName); this.adapters = []; diff --git a/src/vs/workbench/parts/git/electron-browser/electronGitService.ts b/src/vs/workbench/parts/git/electron-browser/electronGitService.ts index fc39d12821b..7c695170f32 100644 --- a/src/vs/workbench/parts/git/electron-browser/electronGitService.ts +++ b/src/vs/workbench/parts/git/electron-browser/electronGitService.ts @@ -23,7 +23,6 @@ import { RawGitService, DelayedRawGitService } from 'vs/workbench/parts/git/node import URI from 'vs/base/common/uri'; import { spawn, exec } from 'child_process'; import { join } from 'path'; -import { remote } from 'electron'; import { IStorageService } from 'vs/platform/storage/common/storage'; import { readdir } from 'vs/base/node/pfs'; @@ -147,7 +146,7 @@ class DisabledRawGitService extends RawGitService { } } -function createRemoteRawGitService(gitPath: string, workspaceRoot: string, encoding: string, verbose: boolean): IRawGitService { +function createRemoteRawGitService(gitPath: string, execPath: string, workspaceRoot: string, encoding: string, verbose: boolean): IRawGitService { const promise = TPromise.timeout(0) // free event loop cos finding git costs .then(() => findGit(gitPath)) .then(({ path, version }) => { @@ -156,7 +155,7 @@ function createRemoteRawGitService(gitPath: string, workspaceRoot: string, encod { serverName: 'Git', timeout: 1000 * 60, - args: [path, workspaceRoot, encoding, remote.process.execPath, version], + args: [path, workspaceRoot, encoding, execPath, version], env: { ATOM_SHELL_INTERNAL_RUN_AS_NODE: 1, PIPE_LOGGING: 'true', @@ -178,11 +177,11 @@ interface IRawGitServiceBootstrap { createRawGitService(gitPath: string, workspaceRoot: string, defaultEncoding: string, exePath: string, version: string): TPromise; } -function createRawGitService(gitPath: string, workspaceRoot: string, encoding: string, verbose: boolean): IRawGitService { +function createRawGitService(gitPath: string, execPath: string, workspaceRoot: string, encoding: string, verbose: boolean): IRawGitService { const promise = new TPromise((c, e) => { require(['vs/workbench/parts/git/node/rawGitServiceBootstrap'], ({ createRawGitService }: IRawGitServiceBootstrap) => { findGit(gitPath) - .then(({ path, version }) => createRawGitService(path, workspaceRoot, encoding, remote.process.execPath, version)) + .then(({ path, version }) => createRawGitService(path, workspaceRoot, encoding, execPath, version)) .done(c, e); }, e); }); @@ -223,9 +222,9 @@ export class ElectronGitService extends GitService { const verbose = !environmentService.isBuilt || environmentService.verbose; if (ElectronGitService.USE_REMOTE_PROCESS_SERVICE) { - raw = createRemoteRawGitService(gitPath, workspaceRoot, encoding, verbose); + raw = createRemoteRawGitService(gitPath, environmentService.execPath, workspaceRoot, encoding, verbose); } else { - raw = createRawGitService(gitPath, workspaceRoot, encoding, verbose); + raw = createRawGitService(gitPath, environmentService.execPath, workspaceRoot, encoding, verbose); } } diff --git a/src/vs/workbench/parts/lib/electron-browser/configVariables.ts b/src/vs/workbench/parts/lib/node/configVariables.ts similarity index 74% rename from src/vs/workbench/parts/lib/electron-browser/configVariables.ts rename to src/vs/workbench/parts/lib/node/configVariables.ts index b4380367257..f99a6047e42 100644 --- a/src/vs/workbench/parts/lib/electron-browser/configVariables.ts +++ b/src/vs/workbench/parts/lib/node/configVariables.ts @@ -10,10 +10,18 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IWorkspaceContextService } from 'vs/workbench/services/workspace/common/contextService'; import URI from 'vs/base/common/uri'; +import { IEnvironmentService } from 'vs/platform/environment/common/environment'; export class ConfigVariables extends SystemVariables { - constructor(private configurationService: IConfigurationService, editorService: IWorkbenchEditorService, contextService: IWorkspaceContextService, workspaceRoot: URI = null, envVariables: { [key: string]: string } = process.env) { - super(editorService, contextService, workspaceRoot, envVariables); + constructor( + private configurationService: IConfigurationService, + editorService: IWorkbenchEditorService, + contextService: IWorkspaceContextService, + environmentService: IEnvironmentService, + workspaceRoot: URI = null, + envVariables: { [key: string]: string } = process.env + ) { + super(editorService, contextService, environmentService, workspaceRoot, envVariables); } protected resolveString(value: string): string { diff --git a/src/vs/workbench/parts/lib/electron-browser/systemVariables.ts b/src/vs/workbench/parts/lib/node/systemVariables.ts similarity index 93% rename from src/vs/workbench/parts/lib/electron-browser/systemVariables.ts rename to src/vs/workbench/parts/lib/node/systemVariables.ts index 6b1ceb01e73..8884c14d614 100644 --- a/src/vs/workbench/parts/lib/electron-browser/systemVariables.ts +++ b/src/vs/workbench/parts/lib/node/systemVariables.ts @@ -12,8 +12,7 @@ import * as WorkbenchEditorCommon from 'vs/workbench/common/editor'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IWorkspaceContextService } from 'vs/workbench/services/workspace/common/contextService'; - -import { remote } from 'electron'; +import { IEnvironmentService } from 'vs/platform/environment/common/environment'; export class SystemVariables extends AbstractSystemVariables { private _workspaceRoot: string; @@ -23,6 +22,7 @@ export class SystemVariables extends AbstractSystemVariables { constructor( private editorService: IWorkbenchEditorService, contextService: IWorkspaceContextService, + environmentService: IEnvironmentService, workspaceRoot: URI = null, envVariables: { [key: string]: string } = process.env ) { @@ -32,7 +32,7 @@ export class SystemVariables extends AbstractSystemVariables { fsPath = workspaceRoot ? workspaceRoot.fsPath : contextService.getWorkspace().resource.fsPath; } this._workspaceRoot = Paths.normalize(fsPath, true); - this._execPath = remote.process.execPath; + this._execPath = environmentService.execPath; Object.keys(envVariables).forEach(key => { this[`env.${key}`] = envVariables[key]; }); diff --git a/src/vs/workbench/parts/lib/test/electron-browser/configVariables.test.ts b/src/vs/workbench/parts/lib/test/node/configVariables.test.ts similarity index 87% rename from src/vs/workbench/parts/lib/test/electron-browser/configVariables.test.ts rename to src/vs/workbench/parts/lib/test/node/configVariables.test.ts index 426566d9e6d..31173a20bef 100644 --- a/src/vs/workbench/parts/lib/test/electron-browser/configVariables.test.ts +++ b/src/vs/workbench/parts/lib/test/node/configVariables.test.ts @@ -7,8 +7,9 @@ import * as assert from 'assert'; import URI from 'vs/base/common/uri'; import * as Platform from 'vs/base/common/platform'; -import { ConfigVariables } from 'vs/workbench/parts/lib/electron-browser/configVariables'; +import { ConfigVariables } from 'vs/workbench/parts/lib/node/configVariables'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; +import {TestEnvironmentService} from 'vs/test/utils/servicesTestUtils'; import {TPromise} from 'vs/base/common/winjs.base'; suite('ConfigVariables tests', () => { @@ -25,7 +26,7 @@ suite('ConfigVariables tests', () => { } }); - let systemVariables: ConfigVariables = new ConfigVariables(configurationService, null, null, URI.parse('file:///VSCode/workspaceLocation')); + let systemVariables: ConfigVariables = new ConfigVariables(configurationService, null, null, TestEnvironmentService, URI.parse('file:///VSCode/workspaceLocation')); assert.strictEqual(systemVariables.resolve('abc ${config.editor.fontFamily} xyz'), 'abc foo xyz'); }); @@ -42,7 +43,7 @@ suite('ConfigVariables tests', () => { } }); - let systemVariables: ConfigVariables = new ConfigVariables(configurationService, null, null, URI.parse('file:///VSCode/workspaceLocation')); + let systemVariables: ConfigVariables = new ConfigVariables(configurationService, null, null, TestEnvironmentService, URI.parse('file:///VSCode/workspaceLocation')); assert.strictEqual(systemVariables.resolve('abc ${config.editor.fontFamily} ${config.terminal.integrated.fontFamily} xyz'), 'abc foo bar xyz'); }); test('SystemVariables: substitute one env variable', () => { @@ -59,7 +60,7 @@ suite('ConfigVariables tests', () => { }); let envVariables: { [key: string]: string } = { key1: 'Value for Key1', key2: 'Value for Key2' }; - let systemVariables: ConfigVariables = new ConfigVariables(configurationService, null, null, URI.parse('file:///VSCode/workspaceLocation'), envVariables); + let systemVariables: ConfigVariables = new ConfigVariables(configurationService, null, null, TestEnvironmentService, URI.parse('file:///VSCode/workspaceLocation'), envVariables); if (Platform.isWindows) { assert.strictEqual(systemVariables.resolve('abc ${config.editor.fontFamily} ${workspaceRoot} ${env.key1} xyz'), 'abc foo \\VSCode\\workspaceLocation Value for Key1 xyz'); } else { @@ -81,7 +82,7 @@ suite('ConfigVariables tests', () => { }); let envVariables: { [key: string]: string } = { key1: 'Value for Key1', key2: 'Value for Key2' }; - let systemVariables: ConfigVariables = new ConfigVariables(configurationService, null, null, URI.parse('file:///VSCode/workspaceLocation'), envVariables); + let systemVariables: ConfigVariables = new ConfigVariables(configurationService, null, null, TestEnvironmentService, URI.parse('file:///VSCode/workspaceLocation'), envVariables); if (Platform.isWindows) { assert.strictEqual(systemVariables.resolve('${config.editor.fontFamily} ${config.terminal.integrated.fontFamily} ${workspaceRoot} - ${workspaceRoot} ${env.key1} - ${env.key2}'), 'foo bar \\VSCode\\workspaceLocation - \\VSCode\\workspaceLocation Value for Key1 - Value for Key2'); } else { @@ -115,7 +116,7 @@ suite('ConfigVariables tests', () => { } }); - let systemVariables: ConfigVariables = new ConfigVariables(configurationService, null, null, URI.parse('file:///VSCode/workspaceLocation')); + let systemVariables: ConfigVariables = new ConfigVariables(configurationService, null, null, TestEnvironmentService, URI.parse('file:///VSCode/workspaceLocation')); assert.strictEqual(systemVariables.resolve('abc ${config.editor.fontFamily} ${config.editor.lineNumbers} ${config.editor.insertSpaces} ${config.json.schemas[0].fileMatch[1]} xyz'), 'abc foo 123 false {{/myOtherfile}} xyz'); }); }); diff --git a/src/vs/workbench/parts/lib/test/electron-browser/systemVariables.test.ts b/src/vs/workbench/parts/lib/test/node/systemVariables.test.ts similarity index 83% rename from src/vs/workbench/parts/lib/test/electron-browser/systemVariables.test.ts rename to src/vs/workbench/parts/lib/test/node/systemVariables.test.ts index fe02628c5d2..a95fc23ade8 100644 --- a/src/vs/workbench/parts/lib/test/electron-browser/systemVariables.test.ts +++ b/src/vs/workbench/parts/lib/test/node/systemVariables.test.ts @@ -7,12 +7,13 @@ import * as assert from 'assert'; import URI from 'vs/base/common/uri'; import * as Platform from 'vs/base/common/platform'; +import {TestEnvironmentService} from 'vs/test/utils/servicesTestUtils'; -import { SystemVariables } from 'vs/workbench/parts/lib/electron-browser/systemVariables'; +import { SystemVariables } from 'vs/workbench/parts/lib/node/systemVariables'; suite('SystemVariables tests', () => { test('SystemVariables: substitute one', () => { - let systemVariables: SystemVariables = new SystemVariables(null, null, URI.parse('file:///VSCode/workspaceLocation')); + let systemVariables: SystemVariables = new SystemVariables(null, null, TestEnvironmentService, URI.parse('file:///VSCode/workspaceLocation')); if (Platform.isWindows) { assert.strictEqual(systemVariables.resolve('abc ${workspaceRoot} xyz'), 'abc \\VSCode\\workspaceLocation xyz'); } else { @@ -21,7 +22,7 @@ suite('SystemVariables tests', () => { }); test('SystemVariables: substitute many', () => { - let systemVariables: SystemVariables = new SystemVariables(null, null, URI.parse('file:///VSCode/workspaceLocation')); + let systemVariables: SystemVariables = new SystemVariables(null, null, TestEnvironmentService, URI.parse('file:///VSCode/workspaceLocation')); if (Platform.isWindows) { assert.strictEqual(systemVariables.resolve('${workspaceRoot} - ${workspaceRoot}'), '\\VSCode\\workspaceLocation - \\VSCode\\workspaceLocation'); } else { @@ -30,7 +31,7 @@ suite('SystemVariables tests', () => { }); test('SystemVariables: substitute one env variable', () => { let envVariables: { [key: string]: string } = { key1: 'Value for Key1', key2: 'Value for Key2' }; - let systemVariables: SystemVariables = new SystemVariables(null, null, URI.parse('file:///VSCode/workspaceLocation'), envVariables); + let systemVariables: SystemVariables = new SystemVariables(null, null, TestEnvironmentService, URI.parse('file:///VSCode/workspaceLocation'), envVariables); if (Platform.isWindows) { assert.strictEqual(systemVariables.resolve('abc ${workspaceRoot} ${env.key1} xyz'), 'abc \\VSCode\\workspaceLocation Value for Key1 xyz'); } else { @@ -40,7 +41,7 @@ suite('SystemVariables tests', () => { test('SystemVariables: substitute many env variable', () => { let envVariables: { [key: string]: string } = { key1: 'Value for Key1', key2: 'Value for Key2' }; - let systemVariables: SystemVariables = new SystemVariables(null, null, URI.parse('file:///VSCode/workspaceLocation'), envVariables); + let systemVariables: SystemVariables = new SystemVariables(null, null, TestEnvironmentService, URI.parse('file:///VSCode/workspaceLocation'), envVariables); if (Platform.isWindows) { assert.strictEqual(systemVariables.resolve('${workspaceRoot} - ${workspaceRoot} ${env.key1} - ${env.key2}'), '\\VSCode\\workspaceLocation - \\VSCode\\workspaceLocation Value for Key1 - Value for Key2'); } else { diff --git a/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts b/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts index 37caab456a4..361e3706c9c 100644 --- a/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts +++ b/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts @@ -56,7 +56,7 @@ import { IPartService } from 'vs/workbench/services/part/common/partService'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IWorkspaceContextService } from 'vs/workbench/services/workspace/common/contextService'; -import { ConfigVariables } from 'vs/workbench/parts/lib/electron-browser/configVariables'; +import { ConfigVariables } from 'vs/workbench/parts/lib/node/configVariables'; import { ITextFileService, EventType } from 'vs/workbench/parts/files/common/files'; import { IOutputService, IOutputChannelRegistry, Extensions as OutputExt, IOutputChannel } from 'vs/workbench/parts/output/common/output'; @@ -65,9 +65,11 @@ import { ITaskService, TaskServiceEvents } from 'vs/workbench/parts/tasks/common import { templates as taskTemplates } from 'vs/workbench/parts/tasks/common/taskTemplates'; import { LanguageServiceTaskSystem, LanguageServiceTaskConfiguration } from 'vs/workbench/parts/tasks/common/languageServiceTaskSystem'; -import * as FileConfig from 'vs/workbench/parts/tasks/electron-browser/processRunnerConfiguration'; -import { ProcessRunnerSystem } from 'vs/workbench/parts/tasks/electron-browser/processRunnerSystem'; -import { ProcessRunnerDetector } from 'vs/workbench/parts/tasks/electron-browser/processRunnerDetector'; +import * as FileConfig from 'vs/workbench/parts/tasks/node/processRunnerConfiguration'; +import { ProcessRunnerSystem } from 'vs/workbench/parts/tasks/node/processRunnerSystem'; +import { ProcessRunnerDetector } from 'vs/workbench/parts/tasks/node/processRunnerDetector'; + +import {IEnvironmentService} from 'vs/platform/environment/common/environment'; let $ = Builder.$; @@ -184,7 +186,8 @@ class ConfigureTaskRunnerAction extends Action { constructor(id: string, label: string, @IConfigurationService configurationService: IConfigurationService, @IWorkbenchEditorService editorService: IWorkbenchEditorService, @IFileService fileService: IFileService, @IWorkspaceContextService contextService: IWorkspaceContextService, @IOutputService outputService: IOutputService, - @IMessageService messageService: IMessageService, @IQuickOpenService quickOpenService: IQuickOpenService) { + @IMessageService messageService: IMessageService, @IQuickOpenService quickOpenService: IQuickOpenService, + @IEnvironmentService private environmentService: IEnvironmentService) { super(id, label); this.configurationService = configurationService; @@ -216,7 +219,7 @@ class ConfigureTaskRunnerAction extends Action { const outputChannel = this.outputService.getChannel(TaskService.OutputChannelId); outputChannel.show(); outputChannel.append(nls.localize('ConfigureTaskRunnerAction.autoDetecting', 'Auto detecting tasks for {0}', selection.id) + '\n'); - let detector = new ProcessRunnerDetector(this.fileService, this.contextService, new ConfigVariables(this.configurationService, this.editorService, this.contextService)); + let detector = new ProcessRunnerDetector(this.fileService, this.contextService, new ConfigVariables(this.configurationService, this.editorService, this.contextService, this.environmentService)); contentPromise = detector.detect(false, selection.id).then((value) => { let config = value.config; if (value.stderr && value.stderr.length > 0) { @@ -585,7 +588,8 @@ class TaskService extends EventEmitter implements ITaskService { @ITelemetryService telemetryService: ITelemetryService, @ITextFileService textFileService:ITextFileService, @ILifecycleService lifecycleService: ILifecycleService, @IEventService eventService: IEventService, @IModelService modelService: IModelService, @IExtensionService extensionService: IExtensionService, - @IQuickOpenService quickOpenService: IQuickOpenService) { + @IQuickOpenService quickOpenService: IQuickOpenService, + @IEnvironmentService private environmentService: IEnvironmentService) { super(); this.modeService = modeService; @@ -637,7 +641,7 @@ class TaskService extends EventEmitter implements ITaskService { this._taskSystem = new NullTaskSystem(); this._taskSystemPromise = TPromise.as(this._taskSystem); } else { - let variables = new ConfigVariables(this.configurationService, this.editorService, this.contextService); + let variables = new ConfigVariables(this.configurationService, this.editorService, this.contextService, this.environmentService); let clearOutput = true; this._taskSystemPromise = TPromise.as(this.configurationService.getConfiguration('tasks')).then((config: TaskConfiguration) => { let parseErrors: string[] = config ? (config).$parseErrors : null; @@ -745,7 +749,7 @@ class TaskService extends EventEmitter implements ITaskService { public configureAction(): Action { return new ConfigureTaskRunnerAction(ConfigureTaskRunnerAction.ID, ConfigureTaskRunnerAction.TEXT, this.configurationService, this.editorService, this.fileService, this.contextService, - this.outputService, this.messageService, this.quickOpenService); + this.outputService, this.messageService, this.quickOpenService, this.environmentService); } public build(): TPromise { diff --git a/src/vs/workbench/parts/tasks/electron-browser/processRunnerConfiguration.ts b/src/vs/workbench/parts/tasks/node/processRunnerConfiguration.ts similarity index 100% rename from src/vs/workbench/parts/tasks/electron-browser/processRunnerConfiguration.ts rename to src/vs/workbench/parts/tasks/node/processRunnerConfiguration.ts diff --git a/src/vs/workbench/parts/tasks/electron-browser/processRunnerDetector.ts b/src/vs/workbench/parts/tasks/node/processRunnerDetector.ts similarity index 99% rename from src/vs/workbench/parts/tasks/electron-browser/processRunnerDetector.ts rename to src/vs/workbench/parts/tasks/node/processRunnerDetector.ts index 92bc732878a..65b0bebe92d 100644 --- a/src/vs/workbench/parts/tasks/electron-browser/processRunnerDetector.ts +++ b/src/vs/workbench/parts/tasks/node/processRunnerDetector.ts @@ -14,7 +14,7 @@ import { LineProcess } from 'vs/base/node/processes'; import { IFileService } from 'vs/platform/files/common/files'; -import { SystemVariables } from 'vs/workbench/parts/lib/electron-browser/systemVariables'; +import { SystemVariables } from 'vs/workbench/parts/lib/node/systemVariables'; import { IWorkspaceContextService } from 'vs/workbench/services/workspace/common/contextService'; import * as FileConfig from './processRunnerConfiguration'; diff --git a/src/vs/workbench/parts/tasks/electron-browser/processRunnerSystem.ts b/src/vs/workbench/parts/tasks/node/processRunnerSystem.ts similarity index 100% rename from src/vs/workbench/parts/tasks/electron-browser/processRunnerSystem.ts rename to src/vs/workbench/parts/tasks/node/processRunnerSystem.ts diff --git a/src/vs/workbench/parts/tasks/test/electron-browser/configuration.test.ts b/src/vs/workbench/parts/tasks/test/node/configuration.test.ts similarity index 99% rename from src/vs/workbench/parts/tasks/test/electron-browser/configuration.test.ts rename to src/vs/workbench/parts/tasks/test/node/configuration.test.ts index eabcaa72275..b98a68d7cb6 100644 --- a/src/vs/workbench/parts/tasks/test/electron-browser/configuration.test.ts +++ b/src/vs/workbench/parts/tasks/test/node/configuration.test.ts @@ -11,7 +11,7 @@ import * as Platform from 'vs/base/common/platform'; import { ProblemMatcher, FileLocationKind, ProblemPattern, ApplyToKind } from 'vs/platform/markers/common/problemMatcher'; import * as TaskSystem from 'vs/workbench/parts/tasks/common/taskSystem'; -import { parse, ParseResult, ILogger, ExternalTaskRunnerConfiguration } from 'vs/workbench/parts/tasks/electron-browser/processRunnerConfiguration'; +import { parse, ParseResult, ILogger, ExternalTaskRunnerConfiguration } from 'vs/workbench/parts/tasks/node/processRunnerConfiguration'; class Logger implements ILogger { public receivedMessage: boolean = false; -- GitLab