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