refactgor bootstrap-amd
This commit is contained in:
parent
cf1e93a5f4
commit
cf6884c01e
49
src/bootstrap-amd.js
vendored
49
src/bootstrap-amd.js
vendored
|
@ -4,51 +4,10 @@
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
var fs = require('fs');
|
||||||
|
var app = require('electron').app;
|
||||||
var loader = require('./vs/loader');
|
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++) {
|
|
||||||
var arg = process.argv[i];
|
|
||||||
if (arg.slice(0, localeOpts.length) == localeOpts) {
|
|
||||||
var segments = arg.split('=');
|
|
||||||
locale = segments[1];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (locale === 'pseudo') {
|
|
||||||
return { availableLanguages: {}, pseudo: true }
|
|
||||||
}
|
|
||||||
if (process.env.VSCODE_DEV) {
|
|
||||||
return { availableLanguages: {} };
|
|
||||||
}
|
|
||||||
// We have a built version so we have extracted nls file. Try to find
|
|
||||||
// the right file to use.
|
|
||||||
locale = locale || app.getLocale();
|
|
||||||
while (locale) {
|
|
||||||
var candidate = path.join(__dirname, 'main.nls.') + locale + '.js';
|
|
||||||
if (fs.existsSync(candidate)) {
|
|
||||||
return { availableLanguages: { '*': locale } };
|
|
||||||
} else {
|
|
||||||
var index = locale.lastIndexOf('-');
|
|
||||||
if (index > 0) {
|
|
||||||
locale = locale.substring(0, index);
|
|
||||||
} else {
|
|
||||||
locale = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return { availableLanguages: {} };
|
|
||||||
}
|
|
||||||
|
|
||||||
function uriFromPath(_path) {
|
function uriFromPath(_path) {
|
||||||
var pathName = path.resolve(_path).replace(/\\/g, '/');
|
var pathName = path.resolve(_path).replace(/\\/g, '/');
|
||||||
|
|
||||||
|
@ -59,8 +18,8 @@ function uriFromPath(_path) {
|
||||||
return encodeURI('file://' + pathName);
|
return encodeURI('file://' + pathName);
|
||||||
}
|
}
|
||||||
|
|
||||||
var nlsConfig = getNLSConfiguration();
|
var rawNlsConfig = process.env['VSCODE_NLS_CONFIG'];
|
||||||
process.env['VSCODE_NLS_CONFIG'] = JSON.stringify(nlsConfig);
|
var nlsConfig = rawNlsConfig ? JSON.parse(rawNlsConfig) : { availableLanguages:{} };
|
||||||
|
|
||||||
loader.config({
|
loader.config({
|
||||||
baseUrl: uriFromPath(path.join(__dirname)),
|
baseUrl: uriFromPath(path.join(__dirname)),
|
||||||
|
|
43
src/main.js
43
src/main.js
|
@ -7,8 +7,48 @@
|
||||||
global.vscodeStart = Date.now();
|
global.vscodeStart = Date.now();
|
||||||
|
|
||||||
var app = require('electron').app;
|
var app = require('electron').app;
|
||||||
|
var fs = require('fs');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
|
||||||
|
// Duplicated in ../index.html for the renderes.
|
||||||
|
function getNLSConfiguration() {
|
||||||
|
var locale = undefined;
|
||||||
|
var localeOpts = '--locale';
|
||||||
|
for (var i = 0; i < process.argv.length; i++) {
|
||||||
|
var arg = process.argv[i];
|
||||||
|
if (arg.slice(0, localeOpts.length) == localeOpts) {
|
||||||
|
var segments = arg.split('=');
|
||||||
|
locale = segments[1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (locale === 'pseudo') {
|
||||||
|
return { availableLanguages: {}, pseudo: true }
|
||||||
|
}
|
||||||
|
if (process.env.VSCODE_DEV) {
|
||||||
|
return { availableLanguages: {} };
|
||||||
|
}
|
||||||
|
// We have a built version so we have extracted nls file. Try to find
|
||||||
|
// the right file to use.
|
||||||
|
locale = locale || app.getLocale();
|
||||||
|
while (locale) {
|
||||||
|
var candidate = path.join(__dirname, 'main.nls.') + locale + '.js';
|
||||||
|
if (fs.existsSync(candidate)) {
|
||||||
|
return { availableLanguages: { '*': locale } };
|
||||||
|
} else {
|
||||||
|
var index = locale.lastIndexOf('-');
|
||||||
|
if (index > 0) {
|
||||||
|
locale = locale.substring(0, index);
|
||||||
|
} else {
|
||||||
|
locale = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { availableLanguages: {} };
|
||||||
|
}
|
||||||
|
|
||||||
// Change cwd if given via env variable
|
// Change cwd if given via env variable
|
||||||
try {
|
try {
|
||||||
if (process.env.VSCODE_CWD) {
|
if (process.env.VSCODE_CWD) {
|
||||||
|
@ -31,6 +71,9 @@ app.on('open-file', function(event, path) {
|
||||||
global.macOpenFiles.push(path);
|
global.macOpenFiles.push(path);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var nlsConfig = getNLSConfiguration();
|
||||||
|
process.env['VSCODE_NLS_CONFIG'] = JSON.stringify(nlsConfig);
|
||||||
|
|
||||||
// Load our code once ready
|
// Load our code once ready
|
||||||
app.once('ready', function() {
|
app.once('ready', function() {
|
||||||
process.env['AMD_ENTRYPOINT'] = 'vs/workbench/electron-main/main';
|
process.env['AMD_ENTRYPOINT'] = 'vs/workbench/electron-main/main';
|
||||||
|
|
Loading…
Reference in a new issue