vscode-languageclient
Advanced tools
Comparing version 2.2.0 to 2.2.1
@@ -38,2 +38,3 @@ import * as cp from 'child_process'; | ||
args?: string[]; | ||
runtime?: string; | ||
options?: ForkOptions; | ||
@@ -40,0 +41,0 @@ } |
@@ -472,2 +472,10 @@ /* -------------------------------------------------------------------------------------------- | ||
var _this = this; | ||
function getEnvironment(env) { | ||
if (!env) { | ||
return process.env; | ||
} | ||
var result = Object.create(null); | ||
Object.keys(process.env).forEach(function (key) { return result[key] = process.env[key]; }); | ||
Object.keys(env).forEach(function (key) { return result[key] = env[key]; }); | ||
} | ||
var server = this._serverOptions; | ||
@@ -503,24 +511,67 @@ // We got a function. | ||
var node_1 = json; | ||
return new Promise(function (resolve, reject) { | ||
if (node_1.runtime) { | ||
var args_1 = []; | ||
var options = node_1.options || Object.create(null); | ||
options.execArgv = options.execArgv || []; | ||
options.cwd = options.cwd || vscode_1.workspace.rootPath; | ||
electron.fork(node_1.module, node_1.args || [], options, function (error, cp) { | ||
if (error) { | ||
reject(error); | ||
} | ||
else { | ||
_this._childProcess = cp; | ||
if (node_1.transport === TransportKind.ipc) { | ||
cp.stdout.on('data', function (data) { | ||
_this.outputChannel.append(data.toString()); | ||
}); | ||
resolve(createConnection(new vscode_jsonrpc_1.IPCMessageReader(_this._childProcess), new vscode_jsonrpc_1.IPCMessageWriter(_this._childProcess))); | ||
if (options.execArgv) { | ||
options.execArgv.forEach(function (element) { return args_1.push(element); }); | ||
} | ||
args_1.push(node_1.module); | ||
if (node_1.args) { | ||
node_1.args.forEach(function (element) { return args_1.push(element); }); | ||
} | ||
var execOptions = Object.create(null); | ||
execOptions.cwd = options.cwd || vscode_1.workspace.rootPath; | ||
execOptions.env = getEnvironment(options.env); | ||
if (node_1.transport === TransportKind.ipc) { | ||
execOptions.stdio = [null, null, null, 'ipc']; | ||
} | ||
var process_1 = cp.spawn(node_1.runtime, args_1, execOptions); | ||
if (!process_1 || !process_1.pid) { | ||
return Promise.reject("Launching server using runtime " + node_1.runtime + " failed."); | ||
} | ||
process_1.once('error', function (error) { | ||
_this._childProcess = null; | ||
// ToDo more work to restart server on crash... | ||
console.error('Starting runtime failed'); | ||
}); | ||
process_1.once('close', function (data) { | ||
_this._childProcess = null; | ||
// ToDo more work to restart server on crash... | ||
console.error('Server closed.'); | ||
}); | ||
this._childProcess = process_1; | ||
// A spawned process doesn't have ipc transport even if we spawn node. For now always use stdio communication. | ||
if (node_1.transport === TransportKind.ipc) { | ||
process_1.stdout.on('data', function (data) { return _this.outputChannel.append(data.toString()); }); | ||
process_1.stderr.on('data', function (data) { return _this.outputChannel.append(data.toString()); }); | ||
return Promise.resolve(createConnection(new vscode_jsonrpc_1.IPCMessageReader(process_1), new vscode_jsonrpc_1.IPCMessageWriter(process_1))); | ||
} | ||
else { | ||
return Promise.resolve(createConnection(process_1.stdout, process_1.stdin)); | ||
} | ||
} | ||
else { | ||
return new Promise(function (resolve, reject) { | ||
var options = node_1.options || Object.create(null); | ||
options.execArgv = options.execArgv || []; | ||
options.cwd = options.cwd || vscode_1.workspace.rootPath; | ||
electron.fork(node_1.module, node_1.args || [], options, function (error, cp) { | ||
if (error) { | ||
reject(error); | ||
} | ||
else { | ||
resolve(createConnection(cp.stdout, cp.stdin)); | ||
_this._childProcess = cp; | ||
if (node_1.transport === TransportKind.ipc) { | ||
cp.stdout.on('data', function (data) { | ||
_this.outputChannel.append(data.toString()); | ||
}); | ||
resolve(createConnection(new vscode_jsonrpc_1.IPCMessageReader(_this._childProcess), new vscode_jsonrpc_1.IPCMessageWriter(_this._childProcess))); | ||
} | ||
else { | ||
resolve(createConnection(cp.stdout, cp.stdin)); | ||
} | ||
} | ||
} | ||
}); | ||
}); | ||
}); | ||
} | ||
} | ||
@@ -531,5 +582,5 @@ else if (is.defined(json.command)) { | ||
options.cwd = options.cwd || vscode_1.workspace.rootPath; | ||
var process_1 = cp.spawn(command.command, command.args, command.options); | ||
this._childProcess = process_1; | ||
return Promise.resolve(createConnection(process_1.stdout, process_1.stdin)); | ||
var process_2 = cp.spawn(command.command, command.args, command.options); | ||
this._childProcess = process_2; | ||
return Promise.resolve(createConnection(process_2.stdout, process_2.stdin)); | ||
} | ||
@@ -536,0 +587,0 @@ return Promise.reject(new Error("Unsupported server configuartion " + JSON.stringify(server, null, 4))); |
{ | ||
"name": "vscode-languageclient", | ||
"description": "VSCode Language client implementation", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"author": "Microsoft Corporation", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
181112
4553
12