parent
ff061902a7
commit
18beedd450
|
@ -17,6 +17,7 @@ if not exist out node .\node_modules\gulp\bin\gulp.js compile
|
|||
:: Configuration
|
||||
set NODE_ENV=development
|
||||
set VSCODE_DEV=1
|
||||
set VSCODE_CLI=1
|
||||
set ELECTRON_DEFAULT_ERROR_MODE=1
|
||||
set ELECTRON_ENABLE_LOGGING=1
|
||||
set ELECTRON_ENABLE_STACK_DUMPING=1
|
||||
|
|
|
@ -22,6 +22,7 @@ function code() {
|
|||
# Configuration
|
||||
export NODE_ENV=development
|
||||
export VSCODE_DEV=1
|
||||
export VSCODE_CLI=1
|
||||
export ELECTRON_ENABLE_LOGGING=1
|
||||
export ELECTRON_ENABLE_STACK_DUMPING=1
|
||||
|
||||
|
|
|
@ -44,10 +44,10 @@ if (typeof process === 'object') {
|
|||
_isMacintosh = (process.platform === 'darwin');
|
||||
_isLinux = (process.platform === 'linux');
|
||||
_isRootUser = !_isWindows && (process.getuid() === 0);
|
||||
let vscode_nls_config = process.env['VSCODE_NLS_CONFIG'];
|
||||
if (vscode_nls_config) {
|
||||
let rawNlsConfig = process.env['VSCODE_NLS_CONFIG'];
|
||||
if (rawNlsConfig) {
|
||||
try {
|
||||
let nlsConfig:NLSConfig = JSON.parse(vscode_nls_config);
|
||||
let nlsConfig:NLSConfig = JSON.parse(rawNlsConfig);
|
||||
let resolved = nlsConfig.availableLanguages['*'];
|
||||
_locale = nlsConfig.locale;
|
||||
// VSCode's default language is 'en'
|
||||
|
|
|
@ -269,7 +269,7 @@ interface IEnv {
|
|||
[key: string]: string;
|
||||
}
|
||||
|
||||
function getUnixUserEnvironment(): TPromise<IEnv> {
|
||||
function getUnixShellEnvironment(): TPromise<IEnv> {
|
||||
const promise = new TPromise((c, e) => {
|
||||
const runAsNode = process.env['ATOM_SHELL_INTERNAL_RUN_AS_NODE'];
|
||||
const noAttach = process.env['ELECTRON_NO_ATTACH_CONSOLE'];
|
||||
|
@ -328,20 +328,20 @@ function getUnixUserEnvironment(): TPromise<IEnv> {
|
|||
}
|
||||
|
||||
/**
|
||||
* On Unix systems, we might need to get the environment
|
||||
* from a user's shell. This should only be done when Code
|
||||
* is not launched from a Terminal.
|
||||
* We eed to get the environment from a user's shell.
|
||||
* This should only be done when Code itself is not launched
|
||||
* from within a shell.
|
||||
*/
|
||||
function getUserShellEnvironment(): TPromise<IEnv> {
|
||||
if (platform.isWindows) {
|
||||
return TPromise.as({});
|
||||
}
|
||||
|
||||
function getShellEnvironment(): TPromise<IEnv> {
|
||||
if (process.env['VSCODE_CLI'] === '1') {
|
||||
return TPromise.as({});
|
||||
}
|
||||
|
||||
return getUnixUserEnvironment();
|
||||
if (platform.isWindows) {
|
||||
return TPromise.as({});
|
||||
}
|
||||
|
||||
return getUnixShellEnvironment();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -349,32 +349,29 @@ function getUserShellEnvironment(): TPromise<IEnv> {
|
|||
* Such environment needs to be propagated to the renderer/shared
|
||||
* processes.
|
||||
*/
|
||||
function getUserEnvironment(): TPromise<IEnv> {
|
||||
return getUserShellEnvironment().then(userShellEnv => {
|
||||
function getEnvironment(): TPromise<IEnv> {
|
||||
return getShellEnvironment().then(shellEnv => {
|
||||
return instantiationService.invokeFunction(a => {
|
||||
const envService = a.get(IEnvironmentService);
|
||||
const instanceEnv = {
|
||||
VSCODE_PID: String(process.pid),
|
||||
VSCODE_IPC_HOOK: envService.mainIPCHandle,
|
||||
VSCODE_SHARED_IPC_HOOK: envService.sharedIPCHandle
|
||||
VSCODE_SHARED_IPC_HOOK: envService.sharedIPCHandle,
|
||||
VSCODE_NLS_CONFIG: process.env['VSCODE_NLS_CONFIG']
|
||||
};
|
||||
|
||||
return assign({}, userShellEnv, instanceEnv);
|
||||
return assign({}, shellEnv, instanceEnv);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// On some platforms we need to manually read from the global environment variables
|
||||
// and assign them to the process environment (e.g. when doubleclick app on Mac)
|
||||
getUserEnvironment().then(userEnv => {
|
||||
assign(process.env, userEnv);
|
||||
|
||||
// Make sure the NLS Config travels to the rendered process
|
||||
// See also https://github.com/Microsoft/vscode/issues/4558
|
||||
userEnv['VSCODE_NLS_CONFIG'] = process.env['VSCODE_NLS_CONFIG'];
|
||||
getEnvironment().then(env => {
|
||||
assign(process.env, env);
|
||||
|
||||
return instantiationService.invokeFunction(a => a.get(IEnvironmentService).createPaths())
|
||||
.then(() => instantiationService.invokeFunction(setupIPC))
|
||||
.then(ipcServer => instantiationService.invokeFunction(main, ipcServer, userEnv));
|
||||
.then(ipcServer => instantiationService.invokeFunction(main, ipcServer, env));
|
||||
})
|
||||
.done(null, err => instantiationService.invokeFunction(quit, err));
|
|
@ -99,35 +99,42 @@
|
|||
|
||||
process.on('uncaughtException', function(error) { onError(error, enableDeveloperTools) });
|
||||
}
|
||||
|
||||
function assign(destination, source) {
|
||||
source => Object.keys(source).forEach(key => destination[key] = source[key]);
|
||||
return destination;
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- Startup Code -->
|
||||
<script type="text/javascript">
|
||||
var webFrame = require('electron').webFrame;
|
||||
|
||||
var mainStarted = false;
|
||||
var webFrame = require('electron').webFrame;
|
||||
var args = parseURLQueryArgs();
|
||||
var configuration = JSON.parse(args['config']);
|
||||
var configuration = JSON.parse(args['config']) || {};
|
||||
var enableDeveloperTools = !configuration.isBuilt || !!configuration.extensionDevelopmentPath;
|
||||
|
||||
// Correctly inherit the parent's environment
|
||||
assign(process.env, configuration.userEnv);
|
||||
|
||||
// Get the nls configuration into the process.env as early as possible.
|
||||
var nlsConfig = { availableLanguages: {} };
|
||||
if (configuration.userEnv && configuration.userEnv['VSCODE_NLS_CONFIG']) {
|
||||
var config = configuration.userEnv['VSCODE_NLS_CONFIG'];
|
||||
var config = process.env['VSCODE_NLS_CONFIG'];
|
||||
if (config) {
|
||||
process.env['VSCODE_NLS_CONFIG'] = config;
|
||||
try {
|
||||
if (config) {
|
||||
nlsConfig = JSON.parse(config);
|
||||
} catch (e) {}
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
var locale = nlsConfig.availableLanguages['*'] || 'en';
|
||||
|
||||
if (locale === 'zh-tw') {
|
||||
locale = 'zh-Hant';
|
||||
} else if (locale === 'zh-cn') {
|
||||
locale = 'zh-Hans';
|
||||
}
|
||||
|
||||
window.document.documentElement.setAttribute('lang', locale);
|
||||
|
||||
registerListeners(enableDeveloperTools);
|
||||
|
@ -193,19 +200,18 @@
|
|||
timers.beforeLoad = new Date();
|
||||
|
||||
require([
|
||||
'vs/workbench/electron-browser/main',
|
||||
'vs/workbench/workbench.main',
|
||||
'vs/nls!vs/workbench/workbench.main',
|
||||
'vs/css!vs/workbench/workbench.main'
|
||||
], function() {
|
||||
], (main) => {
|
||||
timers.afterLoad = new Date();
|
||||
|
||||
var main = require('vs/workbench/electron-browser/main');
|
||||
main.startup(configuration, globalSettings).then(function() {
|
||||
mainStarted = true;
|
||||
}, function(error) { onError(error, enableDeveloperTools) });
|
||||
main
|
||||
.startup(configuration, globalSettings)
|
||||
.done(null, error => onError(error, enableDeveloperTools));
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body class="monaco-shell vs-dark" aria-label="">
|
||||
|
|
|
@ -12,7 +12,6 @@ import errors = require('vs/base/common/errors');
|
|||
import platform = require('vs/base/common/platform');
|
||||
import paths = require('vs/base/common/paths');
|
||||
import timer = require('vs/base/common/timer');
|
||||
import {assign} from 'vs/base/common/objects';
|
||||
import uri from 'vs/base/common/uri';
|
||||
import strings = require('vs/base/common/strings');
|
||||
import {IResourceInput} from 'vs/platform/editor/common/editor';
|
||||
|
@ -20,10 +19,8 @@ import {EventService} from 'vs/platform/event/common/eventService';
|
|||
import {WorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService';
|
||||
import {IWorkspace, IConfiguration, IEnvironment} from 'vs/platform/workspace/common/workspace';
|
||||
import {ConfigurationService} from 'vs/workbench/services/configuration/node/configurationService';
|
||||
|
||||
import path = require('path');
|
||||
import fs = require('fs');
|
||||
|
||||
import gracefulFs = require('graceful-fs');
|
||||
gracefulFs.gracefulify(fs);
|
||||
|
||||
|
@ -56,9 +53,6 @@ export interface IMainEnvironment extends IEnvironment {
|
|||
}
|
||||
|
||||
export function startup(environment: IMainEnvironment, globalSettings: IGlobalSettings): winjs.TPromise<void> {
|
||||
// Inherit the user environment
|
||||
assign(process.env, environment.userEnv);
|
||||
|
||||
// Shell Configuration
|
||||
let shellConfiguration: IConfiguration = {
|
||||
env: environment
|
||||
|
|
Loading…
Reference in a new issue