mirror of
https://github.com/Microsoft/vscode
synced 2024-08-24 19:46:05 +00:00
parent
9f9aa618ac
commit
44a565c814
|
@ -5,7 +5,7 @@
|
|||
"author": {
|
||||
"name": "Microsoft Corporation"
|
||||
},
|
||||
"main": "./out/vs/workbench/electron-main/bootstrap",
|
||||
"main": "./out/main",
|
||||
"private": true,
|
||||
"engines": {
|
||||
"node": ">= 0.10.0 < 0.11.0"
|
||||
|
|
|
@ -3,52 +3,15 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
/* global __filename, __dirname, global, process */
|
||||
|
||||
// Perf measurements
|
||||
global.vscodeStart = Date.now();
|
||||
|
||||
var app = require('electron').app;
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
|
||||
// Change cwd if given via env variable
|
||||
try {
|
||||
process.env.VSCODE_CWD && process.chdir(process.env.VSCODE_CWD);
|
||||
} catch (err) {
|
||||
// noop
|
||||
}
|
||||
|
||||
// Set path according to being built or not
|
||||
if (!!process.env.VSCODE_DEV) {
|
||||
var appData = app.getPath('appData');
|
||||
app.setPath('userData', path.join(appData, 'Code-Development'));
|
||||
}
|
||||
|
||||
// Mac: when someone drops a file to the not-yet running VSCode, the open-file event fires even before
|
||||
// the app-ready event. We listen very early for open-file and remember this upon startup as path to open.
|
||||
global.macOpenFiles = [];
|
||||
app.on('open-file', function(event, path) {
|
||||
global.macOpenFiles.push(path);
|
||||
});
|
||||
|
||||
// TODO: Duplicated in:
|
||||
// * src\bootstrap.js
|
||||
// * src\vs\workbench\electron-main\bootstrap.js
|
||||
// * src\vs\platform\plugins\common\nativePluginService.ts
|
||||
function uriFromPath(_path) {
|
||||
var pathName = path.resolve(_path).replace(/\\/g, '/');
|
||||
|
||||
if (pathName.length > 0 && pathName.charAt(0) !== '/') {
|
||||
pathName = '/' + pathName;
|
||||
}
|
||||
|
||||
return encodeURI('file://' + pathName);
|
||||
}
|
||||
|
||||
var loader = require('./vs/loader');
|
||||
|
||||
// Duplicated in ../index.html for the renderes.
|
||||
function getNLSConfiguration() {
|
||||
if (process.env['VSCODE_NLS_CONFIG']) {
|
||||
return JSON.parse(process.env['VSCODE_NLS_CONFIG']);
|
||||
}
|
||||
|
||||
var locale = undefined;
|
||||
var localeOpts = '--locale';
|
||||
for (var i = 0; i < process.argv.length; i++) {
|
||||
|
@ -82,29 +45,38 @@ function getNLSConfiguration() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { availableLanguages: {} };
|
||||
}
|
||||
|
||||
// Load our code once ready
|
||||
app.once('ready', function() {
|
||||
var nlsConfig = getNLSConfiguration();
|
||||
process.env['VSCODE_NLS_CONFIG'] = JSON.stringify(nlsConfig);
|
||||
function uriFromPath(_path) {
|
||||
var pathName = path.resolve(_path).replace(/\\/g, '/');
|
||||
|
||||
var loader = require('../../loader');
|
||||
loader.config({
|
||||
nodeRequire: require,
|
||||
nodeMain: __filename,
|
||||
baseUrl: uriFromPath(path.dirname(path.dirname(path.dirname((__dirname))))),
|
||||
'vs/nls': nlsConfig
|
||||
});
|
||||
|
||||
if (nlsConfig.pseudo) {
|
||||
loader(['vs/nls'], function(nlsPlugin) {
|
||||
nlsPlugin.setPseudoTranslation(nlsConfig.pseudo);
|
||||
});
|
||||
if (pathName.length > 0 && pathName.charAt(0) !== '/') {
|
||||
pathName = '/' + pathName;
|
||||
}
|
||||
|
||||
loader(['vs/workbench/electron-main/main'], function(main) {
|
||||
// Loading done
|
||||
}, function (err) { console.error(err); });
|
||||
});
|
||||
return encodeURI('file://' + pathName);
|
||||
}
|
||||
|
||||
var nlsConfig = getNLSConfiguration();
|
||||
process.env['VSCODE_NLS_CONFIG'] = JSON.stringify(nlsConfig);
|
||||
|
||||
loader.config({
|
||||
baseUrl: uriFromPath(path.join(__dirname)),
|
||||
catchError: true,
|
||||
nodeRequire: require,
|
||||
nodeMain: __filename,
|
||||
'vs/nls': nlsConfig
|
||||
});
|
||||
|
||||
if (nlsConfig.pseudo) {
|
||||
loader(['vs/nls'], function(nlsPlugin) {
|
||||
nlsPlugin.setPseudoTranslation(nlsConfig.pseudo);
|
||||
});
|
||||
}
|
||||
|
||||
var entrypoint = process.env['AMD_ENTRYPOINT'];
|
||||
if (entrypoint) {
|
||||
loader([entrypoint], function () { }, function (err) { console.error(err); });
|
||||
}
|
61
src/bootstrap.js
vendored
61
src/bootstrap.js
vendored
|
@ -86,18 +86,19 @@ if (!!process.send && process.env.PIPE_LOGGING === 'true') {
|
|||
}
|
||||
|
||||
console.error = function () { safeSend({ type: '__$console', severity: 'error', arguments: safeStringify(arguments) }); };
|
||||
|
||||
// Let stdout, stderr and stdin be no-op streams. This prevents an issue where we would get an EBADF
|
||||
// error when we are inside a forked process and this process tries to access those channels.
|
||||
var stream = require('stream');
|
||||
var writable = new stream.Writable({
|
||||
write: function (chunk, encoding, next) { /* No OP */ }
|
||||
});
|
||||
process.__defineGetter__('stdout', function() { return writable; });
|
||||
process.__defineGetter__('stderr', function() { return writable; });
|
||||
process.__defineGetter__('stdin', function() { return writable; });
|
||||
}
|
||||
|
||||
// Let stdout, stderr and stdin be no-op streams. This prevents an issue where we would get an EBADF
|
||||
// error when we are inside a forked process and this process tries to access those channels.
|
||||
var stream = require('stream');
|
||||
var writable = new stream.Writable({
|
||||
write: function (chunk, encoding, next) { /* No OP */ }
|
||||
});
|
||||
|
||||
process.__defineGetter__('stdout', function() { return writable; });
|
||||
process.__defineGetter__('stderr', function() { return writable; });
|
||||
process.__defineGetter__('stdin', function() { return writable; });
|
||||
|
||||
// Handle uncaught exceptions
|
||||
process.on('uncaughtException', function (err) {
|
||||
console.error('Uncaught Exception: ', err.toString());
|
||||
|
@ -106,42 +107,4 @@ process.on('uncaughtException', function (err) {
|
|||
}
|
||||
});
|
||||
|
||||
var path = require('path');
|
||||
var loader = require('./vs/loader');
|
||||
|
||||
// TODO: Duplicated in:
|
||||
// * src\bootstrap.js
|
||||
// * src\vs\workbench\electron-main\bootstrap.js
|
||||
// * src\vs\platform\plugins\common\nativePluginService.ts
|
||||
function uriFromPath(_path) {
|
||||
var pathName = path.resolve(_path).replace(/\\/g, '/');
|
||||
|
||||
if (pathName.length > 0 && pathName.charAt(0) !== '/') {
|
||||
pathName = '/' + pathName;
|
||||
}
|
||||
|
||||
return encodeURI('file://' + pathName);
|
||||
}
|
||||
|
||||
var nlsConfig = undefined;
|
||||
if (process.env.VSCODE_NLS_CONFIG) {
|
||||
nlsConfig = JSON.parse(process.env.VSCODE_NLS_CONFIG);
|
||||
}
|
||||
|
||||
loader.config({
|
||||
baseUrl: uriFromPath(path.join(__dirname)),
|
||||
catchError: true,
|
||||
nodeRequire: require,
|
||||
nodeMain: __filename,
|
||||
'vs/nls': nlsConfig || { availableLanguages: {} }
|
||||
});
|
||||
if (nlsConfig && nlsConfig.pseudo) {
|
||||
loader(['vs/nls'], function(nlsPlugin) {
|
||||
nlsPlugin.setPseudoTranslation(nlsConfig.pseudo);
|
||||
});
|
||||
}
|
||||
|
||||
var entrypoint = process.env.AMD_ENTRYPOINT;
|
||||
if (entrypoint) {
|
||||
loader([entrypoint], function () { }, function (err) { console.error(err); });
|
||||
}
|
||||
require('./bootstrap-amd');
|
38
src/main.js
Normal file
38
src/main.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
// Perf measurements
|
||||
global.vscodeStart = Date.now();
|
||||
|
||||
var app = require('electron').app;
|
||||
var path = require('path');
|
||||
|
||||
// Change cwd if given via env variable
|
||||
try {
|
||||
if (process.env.VSCODE_CWD) {
|
||||
process.chdir(process.env.VSCODE_CWD);
|
||||
}
|
||||
} catch (err) {
|
||||
// noop
|
||||
}
|
||||
|
||||
// Set path according to being built or not
|
||||
if (process.env.VSCODE_DEV) {
|
||||
var appData = app.getPath('appData');
|
||||
app.setPath('userData', path.join(appData, 'Code-Development'));
|
||||
}
|
||||
|
||||
// Mac: when someone drops a file to the not-yet running VSCode, the open-file event fires even before
|
||||
// the app-ready event. We listen very early for open-file and remember this upon startup as path to open.
|
||||
global.macOpenFiles = [];
|
||||
app.on('open-file', function(event, path) {
|
||||
global.macOpenFiles.push(path);
|
||||
});
|
||||
|
||||
// Load our code once ready
|
||||
app.once('ready', function() {
|
||||
process.env['AMD_ENTRYPOINT'] = 'vs/workbench/electron-main/main';
|
||||
require('./bootstrap-amd');
|
||||
});
|
Loading…
Reference in a new issue