fix: improve handling of php executable

pull/387/head v2.3.7
Felix Becker 2018-11-11 05:16:58 +01:00
parent ba3c42d35a
commit 9765c68f5d
3 changed files with 9 additions and 3 deletions

View File

@ -53,6 +53,7 @@
"devDependencies": {
"@commitlint/cli": "7.2.1",
"@commitlint/config-conventional": "7.1.2",
"@types/execa": "0.9.0",
"@types/mocha": "5.2.5",
"@types/mz": "0.0.32",
"@types/node": "8.10.29",
@ -65,6 +66,7 @@
"vscode": "1.1.21"
},
"dependencies": {
"execa": "1.0.0",
"mz": "2.7.0",
"semver": "5.5.1",
"vscode-languageclient": "5.0.1"

View File

@ -1,16 +1,19 @@
import * as path from 'path';
import { spawn, execFile, ChildProcess } from 'mz/child_process';
import { spawn, ChildProcess } from 'mz/child_process';
import * as vscode from 'vscode';
import { LanguageClient, LanguageClientOptions, StreamInfo } from 'vscode-languageclient';
import * as semver from 'semver';
import * as net from 'net';
import * as url from 'url';
import execa from 'execa';
export async function activate(context: vscode.ExtensionContext): Promise<void> {
const conf = vscode.workspace.getConfiguration('php');
const executablePath = conf.get<string>('executablePath') || 'php';
const executablePath = conf.get<string>('executablePath') ||
conf.get<string>('validate.executablePath') ||
(process.platform === 'win32' ? 'php.exe' : 'php');
const memoryLimit = conf.get<string>('memoryLimit') || '4095M';
@ -28,7 +31,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
// Check path (if PHP is available and version is ^7.0.0)
let stdout: string;
try {
[stdout] = await execFile(executablePath, ['--version']);
stdout = await execa.stdout(executablePath, ['--version']);
} catch (err) {
if (err.code === 'ENOENT') {
const selected = await vscode.window.showErrorMessage(

View File

@ -4,6 +4,7 @@
"module": "commonjs",
"moduleResolution": "node",
"outDir": "out",
"esModuleInterop": true,
"lib": [
"es6"
],