more env passing
This commit is contained in:
parent
1bd57ab9b1
commit
89a234b9f0
|
@ -20,6 +20,7 @@ export interface IEnvironmentService {
|
|||
appSettingsPath: string;
|
||||
appKeybindingsPath: string;
|
||||
|
||||
disableExtensions: boolean;
|
||||
extensionsPath: string;
|
||||
extensionDevelopmentPath: string;
|
||||
extensionTestsPath: string;
|
||||
|
|
|
@ -48,6 +48,7 @@ export class EnvironmentService implements IEnvironmentService {
|
|||
get extensionDevelopmentPath(): string { return this._extensionDevelopmentPath; }
|
||||
|
||||
get extensionTestsPath(): string { return this.args.extensionTestsPath; }
|
||||
get disableExtensions(): boolean { return this.args['disable-extensions']; }
|
||||
|
||||
private _debugExtensionHostPort: number;
|
||||
get debugExtensionHostPort(): number { return this._debugExtensionHostPort; }
|
||||
|
|
|
@ -31,7 +31,16 @@ const DIRNAME = URI.parse(require.toUrl('./')).fsPath;
|
|||
const BASE_PATH = paths.normalize(paths.join(DIRNAME, '../../../..'));
|
||||
const BUILTIN_EXTENSIONS_PATH = paths.join(BASE_PATH, 'extensions');
|
||||
|
||||
export interface IEnvironment {
|
||||
appSettingsHome: string;
|
||||
disableExtensions: boolean;
|
||||
userExtensionsHome: string;
|
||||
extensionDevelopmentPath: string;
|
||||
extensionTestsPath: string;
|
||||
}
|
||||
|
||||
export interface IInitData {
|
||||
environment: IEnvironment;
|
||||
threadService: any;
|
||||
contextService: {
|
||||
workspace: any;
|
||||
|
@ -57,11 +66,14 @@ export class ExtensionHostMain {
|
|||
|
||||
private _isTerminating: boolean;
|
||||
private _contextService: IWorkspaceContextService;
|
||||
private _environment: IEnvironment;
|
||||
private _extensionService: ExtHostExtensionService;
|
||||
|
||||
constructor(remoteCom: IMainProcessExtHostIPC, initData: IInitData, sharedProcessClient: Client) {
|
||||
this._isTerminating = false;
|
||||
|
||||
this._environment = initData.environment;
|
||||
|
||||
this._contextService = new BaseWorkspaceContextService(initData.contextService.workspace, initData.contextService.configuration, initData.contextService.options);
|
||||
const workspaceStoragePath = this._getOrCreateWorkspaceStoragePath();
|
||||
|
||||
|
@ -87,7 +99,6 @@ export class ExtensionHostMain {
|
|||
let workspaceStoragePath: string;
|
||||
|
||||
const workspace = this._contextService.getWorkspace();
|
||||
const env = this._contextService.getConfiguration().env;
|
||||
|
||||
function rmkDir(directory: string): boolean {
|
||||
try {
|
||||
|
@ -111,7 +122,7 @@ export class ExtensionHostMain {
|
|||
if (workspace.uid) {
|
||||
hash.update(workspace.uid.toString());
|
||||
}
|
||||
workspaceStoragePath = paths.join(env.appSettingsHome, 'workspaceStorage', hash.digest('hex'));
|
||||
workspaceStoragePath = paths.join(this._environment.appSettingsHome, 'workspaceStorage', hash.digest('hex'));
|
||||
if (!fs.existsSync(workspaceStoragePath)) {
|
||||
try {
|
||||
if (rmkDir(workspaceStoragePath)) {
|
||||
|
@ -162,9 +173,8 @@ export class ExtensionHostMain {
|
|||
|
||||
private readExtensions(): TPromise<void> {
|
||||
let collector = new MessagesCollector();
|
||||
let env = this._contextService.getConfiguration().env;
|
||||
|
||||
return ExtensionHostMain.scanExtensions(collector, BUILTIN_EXTENSIONS_PATH, !env.disableExtensions ? env.userExtensionsHome : void 0, !env.disableExtensions ? env.extensionDevelopmentPath : void 0, pkg.version)
|
||||
return ExtensionHostMain.scanExtensions(collector, BUILTIN_EXTENSIONS_PATH, !this._environment.disableExtensions ? this._environment.userExtensionsHome : void 0, !this._environment.disableExtensions ? this._environment.extensionDevelopmentPath : void 0, pkg.version)
|
||||
.then(null, err => {
|
||||
collector.error('', err);
|
||||
return [];
|
||||
|
@ -263,8 +273,7 @@ export class ExtensionHostMain {
|
|||
}
|
||||
|
||||
private handleExtensionTests(): TPromise<void> {
|
||||
let env = this._contextService.getConfiguration().env;
|
||||
if (!env.extensionTestsPath || !env.extensionDevelopmentPath) {
|
||||
if (!this._environment.extensionTestsPath || !this._environment.extensionDevelopmentPath) {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
|
@ -272,7 +281,7 @@ export class ExtensionHostMain {
|
|||
let testRunner: ITestRunner;
|
||||
let requireError: Error;
|
||||
try {
|
||||
testRunner = <any>require.__$__nodeRequire(env.extensionTestsPath);
|
||||
testRunner = <any>require.__$__nodeRequire(this._environment.extensionTestsPath);
|
||||
} catch (error) {
|
||||
requireError = error;
|
||||
}
|
||||
|
@ -280,7 +289,7 @@ export class ExtensionHostMain {
|
|||
// Execute the runner if it follows our spec
|
||||
if (testRunner && typeof testRunner.run === 'function') {
|
||||
return new TPromise<void>((c, e) => {
|
||||
testRunner.run(env.extensionTestsPath, (error, failures) => {
|
||||
testRunner.run(this._environment.extensionTestsPath, (error, failures) => {
|
||||
if (error) {
|
||||
e(error.toString());
|
||||
} else {
|
||||
|
@ -298,7 +307,7 @@ export class ExtensionHostMain {
|
|||
this.gracefulExit(1 /* ERROR */);
|
||||
}
|
||||
|
||||
return TPromise.wrapError<void>(requireError ? requireError.toString() : nls.localize('extensionTestError', "Path {0} does not point to a valid extension test runner.", env.extensionTestsPath));
|
||||
return TPromise.wrapError<void>(requireError ? requireError.toString() : nls.localize('extensionTestError', "Path {0} does not point to a valid extension test runner.", this._environment.extensionTestsPath));
|
||||
}
|
||||
|
||||
private gracefulExit(code: number): void {
|
||||
|
|
|
@ -168,6 +168,13 @@ class ExtensionHostProcessManager {
|
|||
|
||||
let initPayload = stringify({
|
||||
parentPid: process.pid,
|
||||
environment: {
|
||||
appSettingsHome: this.environmentService.appSettingsHome,
|
||||
disableExtensions: this.environmentService.disableExtensions,
|
||||
userExtensionsHome: this.environmentService.extensionsPath,
|
||||
extensionDevelopmentPath: this.environmentService.extensionDevelopmentPath,
|
||||
extensionTestsPath: this.environmentService.extensionTestsPath
|
||||
},
|
||||
contextService: {
|
||||
workspace: this.contextService.getWorkspace(),
|
||||
configuration: this.contextService.getConfiguration(),
|
||||
|
|
Loading…
Reference in a new issue