From 9765c68f5dad6b1daa3889df781428dfcd547285 Mon Sep 17 00:00:00 2001 From: Felix Becker Date: Sun, 11 Nov 2018 05:16:58 +0100 Subject: [PATCH] fix: improve handling of php executable --- package.json | 2 ++ src/extension.ts | 9 ++++++--- tsconfig.json | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index e85118f2..794a69a8 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/extension.ts b/src/extension.ts index 820c7fab..4e2f0009 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -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 { const conf = vscode.workspace.getConfiguration('php'); - const executablePath = conf.get('executablePath') || 'php'; + const executablePath = conf.get('executablePath') || + conf.get('validate.executablePath') || + (process.platform === 'win32' ? 'php.exe' : 'php'); const memoryLimit = conf.get('memoryLimit') || '4095M'; @@ -28,7 +31,7 @@ export async function activate(context: vscode.ExtensionContext): Promise // 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( diff --git a/tsconfig.json b/tsconfig.json index 243b241b..5a27e0e3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,6 +4,7 @@ "module": "commonjs", "moduleResolution": "node", "outDir": "out", + "esModuleInterop": true, "lib": [ "es6" ],