Skip to content

Commit cb4fcb5

Browse files
committed
Fix version parsing
In the newer versions of CLI each command can print additional warning before the actual command output.
1 parent 373fc16 commit cb4fcb5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/project/nativeScriptCli.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { ILogger } from '../common/logger';
33
import * as utils from '../common/utilities';
44

55
export class NativeScriptCli {
6+
private static CLI_OUTPUT_VERSION_REGEXP = /^(?:\d+\.){2}\d+.*?$/m;
7+
68
private _path: string;
79
private _shellPath: string;
810
private _logger: ILogger;
@@ -24,7 +26,8 @@ export class NativeScriptCli {
2426

2527
public executeGetVersion(): string {
2628
try {
27-
return this.executeSync(['--version'], undefined);
29+
const versionOutput = this.executeSync(['--version'], undefined);
30+
return this.getVersionFromCLIOutput(versionOutput)
2831
} catch (e) {
2932
this._logger.log(e);
3033

@@ -58,4 +61,9 @@ export class NativeScriptCli {
5861

5962
return child;
6063
}
64+
65+
private getVersionFromCLIOutput(commandOutput: string): string {
66+
const matches = commandOutput.match(NativeScriptCli.CLI_OUTPUT_VERSION_REGEXP);
67+
return matches && matches[0];
68+
}
6169
}

0 commit comments

Comments
 (0)