Skip to content

Commit

Permalink
Update utils.js
Browse files Browse the repository at this point in the history
  • Loading branch information
jribbink authored May 23, 2024
1 parent 4d9b1e1 commit 656e875
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,17 @@ export async function getFlowVersion(flowCommand = "flow") {
)
} else {
let versionStr
const rxResult = /^Version: ([^\s]+)/m.exec(stdout)
if (rxResult) {
try {
versionStr = JSON.parse(stdout).version
} catch (error) {
// fallback to regex for older versions of the CLI without JSON output
const rxResult = /^Version: ([^\s]+)/m.exec(stdout)
if (rxResult) {
versionStr = rxResult[1]
}
}
else {
try {
versionStr = JSON.parse(stdout).version
}
catch(error) {
// stdout is not a JSON
}
}

const version = versionStr ? semver.parse(versionStr) : undefined;

const version = versionStr ? semver.parse(versionStr) : undefined
if (!version) {
reject(`Invalid Flow CLI version string: ${versionStr}`)
}
Expand Down

0 comments on commit 656e875

Please sign in to comment.