mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-29 13:03:42 +01:00
make env a pure class
This commit is contained in:
@@ -132,12 +132,6 @@ export class EnvService implements IEnvironmentService {
|
||||
this._currentWorkingDirectory = process.env['VSCODE_CWD'] || process.cwd();
|
||||
this._appHome = app.getPath('userData');
|
||||
this._appSettingsHome = path.join(this._appHome, 'User');
|
||||
|
||||
// TODO move out of here!
|
||||
if (!fs.existsSync(this._appSettingsHome)) {
|
||||
fs.mkdirSync(this._appSettingsHome);
|
||||
}
|
||||
|
||||
this._appSettingsPath = path.join(this._appSettingsHome, 'settings.json');
|
||||
this._appKeybindingsPath = path.join(this._appSettingsHome, 'keybindings.json');
|
||||
|
||||
@@ -189,21 +183,8 @@ export class EnvService implements IEnvironmentService {
|
||||
});
|
||||
|
||||
this._isTestingFromCli = this.cliArgs.extensionTestsPath && !this.cliArgs.debugBrkExtensionHost;
|
||||
|
||||
this._userHome = path.join(app.getPath('home'), product.dataFolderName);
|
||||
|
||||
// TODO move out of here!
|
||||
if (!fs.existsSync(this._userHome)) {
|
||||
fs.mkdirSync(this._userHome);
|
||||
}
|
||||
|
||||
this._userExtensionsHome = this.cliArgs.extensionsHomePath || path.join(this._userHome, 'extensions');
|
||||
|
||||
// TODO move out of here!
|
||||
if (!fs.existsSync(this._userExtensionsHome)) {
|
||||
fs.mkdirSync(this._userExtensionsHome);
|
||||
}
|
||||
|
||||
this._mainIPCHandle = this.getMainIPCHandle();
|
||||
this._sharedIPCHandle = this.getSharedIPCHandle();
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import * as nls from 'vs/nls';
|
||||
import * as fs from 'fs';
|
||||
import { app, ipcMain as ipc } from 'electron';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
import { mkdirp } from 'vs/base/node/pfs';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import { IProcessEnvironment, IEnvironmentService, EnvService } from 'vs/code/electron-main/env';
|
||||
import { IWindowsService, WindowsManager } from 'vs/code/electron-main/windows';
|
||||
@@ -253,6 +254,17 @@ function setupIPC(accessor: ServicesAccessor): TPromise<Server> {
|
||||
return setup(true);
|
||||
}
|
||||
|
||||
// TODO@Joao: what about in the cli process?
|
||||
function createPaths(accessor: ServicesAccessor): TPromise<void> {
|
||||
const environmentService = accessor.get(IEnvironmentService);
|
||||
|
||||
return TPromise.join([
|
||||
mkdirp(environmentService.appSettingsHome),
|
||||
mkdirp(environmentService.userHome),
|
||||
mkdirp(environmentService.userExtensionsHome)
|
||||
]) as any as TPromise<void>;
|
||||
}
|
||||
|
||||
// TODO: isolate
|
||||
const services = new ServiceCollection();
|
||||
|
||||
@@ -282,7 +294,8 @@ getUserEnvironment()
|
||||
// See also https://github.com/Microsoft/vscode/issues/4558
|
||||
userEnv['VSCODE_NLS_CONFIG'] = process.env['VSCODE_NLS_CONFIG'];
|
||||
|
||||
return instantiationService.invokeFunction(setupIPC)
|
||||
return instantiationService.invokeFunction(createPaths)
|
||||
.then(() => instantiationService.invokeFunction(setupIPC))
|
||||
.then(ipcServer => instantiationService.invokeFunction(main, ipcServer, userEnv));
|
||||
})
|
||||
.done(null, err => instantiationService.invokeFunction(quit, err));
|
||||
Reference in New Issue
Block a user