Files
vscode/src/server-cli.js
T
2024-07-09 08:08:56 +02:00

48 lines
2.0 KiB
JavaScript

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// @ts-check
'use strict';
// ESM-comment-begin
const path = require('path');
const bootstrapNode = require('./bootstrap-node');
const bootstrapAmd = require('./bootstrap-amd');
const { resolveNLSConfiguration } = require('./vs/base/node/nls');
const product = require('./bootstrap-meta').product;
// ESM-comment-end
// ESM-uncomment-begin
// import * as path from 'path';
// import { fileURLToPath } from 'url';
// import * as bootstrapNode from './bootstrap-node.js';
// import * as bootstrapAmd from './bootstrap-amd.js';
// import { resolveNLSConfiguration } from './vs/base/node/nls.js';
// import { product } from './bootstrap-meta.js';
//
// const __dirname = path.dirname(fileURLToPath(import.meta.url));
// ESM-uncomment-end
async function start() {
// Keep bootstrap-amd.js from redefining 'fs'.
delete process.env['ELECTRON_RUN_AS_NODE'];
// NLS
const nlsConfiguration = await resolveNLSConfiguration({ userLocale: 'en', osLocale: 'en', commit: product.commit, userDataPath: '', nlsMetadataPath: __dirname });
process.env['VSCODE_NLS_CONFIG'] = JSON.stringify(nlsConfiguration); // required for `bootstrap-amd` to pick up NLS messages
if (process.env['VSCODE_DEV']) {
// When running out of sources, we need to load node modules from remote/node_modules,
// which are compiled against nodejs, not electron
process.env['VSCODE_INJECT_NODE_MODULE_LOOKUP_PATH'] = process.env['VSCODE_INJECT_NODE_MODULE_LOOKUP_PATH'] || path.join(__dirname, '..', 'remote', 'node_modules');
bootstrapNode.injectNodeModuleLookupPath(process.env['VSCODE_INJECT_NODE_MODULE_LOOKUP_PATH']);
} else {
delete process.env['VSCODE_INJECT_NODE_MODULE_LOOKUP_PATH'];
}
bootstrapAmd.load('vs/server/node/server.cli');
}
start();