Skip to content

Commit

Permalink
fix: improve handling of php executable
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfbecker committed Nov 11, 2018
1 parent ba3c42d commit 9765c68
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
Expand Down
9 changes: 6 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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(
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"module": "commonjs",
"moduleResolution": "node",
"outDir": "out",
"esModuleInterop": true,
"lib": [
"es6"
],
Expand Down

0 comments on commit 9765c68

Please sign in to comment.