提交 c93167fe 编写于 作者: D Dirk Baeumer

Fixes #2930: Bad argument

上级 b1d162ca
......@@ -184,41 +184,49 @@ export default class PHPValidationProvider {
} else {
args = PHPValidationProvider.BufferArgs;
}
let childProcess = cp.spawn(executable, args, options);
childProcess.on('error', (error: Error) => {
if (this.executableNotFound) {
try {
let childProcess = cp.spawn(executable, args, options);
childProcess.on('error', (error: Error) => {
if (this.executableNotFound) {
resolve();
return;
}
this.showError(error, executable);
this.executableNotFound = true;
resolve();
return;
}
let message: string = null;
if ((<any>error).code === 'ENOENT') {
message = `Cannot validate the php file. The php program was not found. Use the 'php.validate.executablePath' setting to configure the location of 'php'`;
} else {
message = error.message ? error.message : `Failed to run php using path: ${executable}. Reason is unknown.`;
}
vscode.window.showInformationMessage(message);
this.executableNotFound = true;
resolve();
});
if (childProcess.pid) {
if (this.trigger === RunTrigger.onType) {
childProcess.stdin.write(textDocument.getText());
childProcess.stdin.end();
}
childProcess.stdout.on('data', (data: Buffer) => {
decoder.write(data).forEach(processLine);
});
childProcess.stdout.on('end', () => {
let line = decoder.end();
if (line) {
processLine(line);
if (childProcess.pid) {
if (this.trigger === RunTrigger.onType) {
childProcess.stdin.write(textDocument.getText());
childProcess.stdin.end();
}
this.diagnosticCollection.set(textDocument.uri, diagnostics);
childProcess.stdout.on('data', (data: Buffer) => {
decoder.write(data).forEach(processLine);
});
childProcess.stdout.on('end', () => {
let line = decoder.end();
if (line) {
processLine(line);
}
this.diagnosticCollection.set(textDocument.uri, diagnostics);
resolve();
});
} else {
resolve();
});
} else {
resolve();
}
} catch (error) {
this.showError(error, executable);
}
});
}
private showError(error: any, executable: string): void {
let message: string = null;
if (error.code === 'ENOENT') {
message = `Cannot validate the php file. The php program was not found. Use the 'php.validate.executablePath' setting to configure the location of 'php'`;
} else {
message = error.message ? error.message : `Failed to run php using path: ${executable}. Reason is unknown.`;
}
vscode.window.showInformationMessage(message);
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册