Merge from master

This commit is contained in:
Raj Musuku
2019-02-21 17:56:04 -08:00
parent 5a146e34fa
commit 666ae11639
11482 changed files with 119352 additions and 255574 deletions

87
src/bootstrap-amd.js vendored
View File

@@ -3,88 +3,53 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
var path = require('path');
var fs = require('fs');
var loader = require('./vs/loader');
//@ts-check
'use strict';
function uriFromPath(_path) {
var pathName = path.resolve(_path).replace(/\\/g, '/');
const loader = require('./vs/loader');
const bootstrap = require('./bootstrap');
if (pathName.length > 0 && pathName.charAt(0) !== '/') {
pathName = '/' + pathName;
}
return encodeURI('file://' + pathName);
}
function readFile(file) {
return new Promise(function (resolve, reject) {
fs.readFile(file, 'utf8', function (err, data) {
if (err) {
reject(err);
return;
}
resolve(data);
});
});
}
const writeFile = (file, content) => new Promise((c, e) => fs.writeFile(file, content, 'utf8', err => err ? e(err) : c()));
var rawNlsConfig = process.env['VSCODE_NLS_CONFIG'];
var nlsConfig = rawNlsConfig ? JSON.parse(rawNlsConfig) : { availableLanguages: {} };
// We have a special location of the nls files. They come from a language pack
if (nlsConfig._resolvedLanguagePackCoreLocation) {
let bundles = Object.create(null);
nlsConfig.loadBundle = function (bundle, language, cb) {
let result = bundles[bundle];
if (result) {
cb(undefined, result);
return;
}
let bundleFile = path.join(nlsConfig._resolvedLanguagePackCoreLocation, bundle.replace(/\//g, '!') + '.nls.json');
readFile(bundleFile).then(function (content) {
let json = JSON.parse(content);
bundles[bundle] = json;
cb(undefined, json);
}).catch((error) => {
try {
if (nlsConfig._corruptedFile) {
writeFile(nlsConfig._corruptedFile, 'corrupted').catch(function (error) { console.error(error); });
}
} finally {
cb(error, undefined);
}
});
};
}
// Bootstrap: NLS
const nlsConfig = bootstrap.setupNLS();
// Bootstrap: Loader
loader.config({
baseUrl: uriFromPath(__dirname),
baseUrl: bootstrap.uriFromPath(__dirname),
catchError: true,
nodeRequire: require,
nodeMain: __filename,
'vs/nls': nlsConfig,
nodeCachedDataDir: process.env['VSCODE_NODE_CACHED_DATA_DIR_' + process.pid]
'vs/nls': nlsConfig
});
if (process.env['ELECTRON_RUN_AS_NODE'] || process.versions.electron) {
// running in Electron
loader.define('fs', ['original-fs'], function (originalFS) { return originalFS; }); // replace the patched electron fs with the original node fs for all AMD code
// Running in Electron
if (process.env['ELECTRON_RUN_AS_NODE'] || process.versions['electron']) {
loader.define('fs', ['original-fs'], function (originalFS) {
return originalFS; // replace the patched electron fs with the original node fs for all AMD code
});
}
// Pseudo NLS support
if (nlsConfig.pseudo) {
loader(['vs/nls'], function (nlsPlugin) {
nlsPlugin.setPseudoTranslation(nlsConfig.pseudo);
});
}
exports.bootstrap = function (entrypoint, onLoad, onError) {
exports.load = function (entrypoint, onLoad, onError) {
if (!entrypoint) {
return;
}
// cached data config
if (process.env['VSCODE_NODE_CACHED_DATA_DIR']) {
loader.config({
nodeCachedData: {
path: process.env['VSCODE_NODE_CACHED_DATA_DIR'],
seed: entrypoint
}
});
}
onLoad = onLoad || function () { };
onError = onError || function (err) { console.error(err); };