Handle case where version regexp doesnt match
parent
8cb1a8ea33
commit
1ac5a8fce3
|
@ -23,7 +23,12 @@ export function activate(context: vscode.ExtensionContext) {
|
|||
}
|
||||
|
||||
// Parse version and discard OS info like 7.0.8--0ubuntu0.16.04.2
|
||||
let version = stdout.toString().match(/^PHP ([^\s]+)/)[1].split('-')[0];
|
||||
const match = stdout.toString().match(/^PHP ([^\s]+)/);
|
||||
if (!match) {
|
||||
vscode.window.showErrorMessage('Error parsing PHP version. Please check the output of php --version');
|
||||
return;
|
||||
}
|
||||
let version = match[1].split('-')[0];
|
||||
// Convert PHP prerelease format like 7.0.0rc1 to 7.0.0-rc1
|
||||
if (!/^\d+.\d+.\d+$/.test(version)) {
|
||||
version = version.replace(/(\d+.\d+.\d+)/, '$1-');
|
||||
|
|
Loading…
Reference in New Issue