Skip to content

Commit bfcd31f

Browse files
fix: version detection
1 parent 25974ec commit bfcd31f

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

src/install.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,34 @@ async function getEdgeVersionWin (edgePath: string) {
7272
async function getEdgeVersionUnix (edgePath: string) {
7373
log.info(`Trying to detect Microsoft Edge version from binary found at ${edgePath}`)
7474
const versionOutput = await new Promise<string>((resolve, reject) => cp.exec(`"${edgePath}" --version`, (err, stdout, stderr) => {
75-
console.log(111, err, stdout, stderr)
76-
7775
if (err) {
7876
return reject(err)
7977
}
8078
if (stderr) {
8179
return reject(new Error(stderr))
8280
}
83-
console.log('RESOVE', stdout)
8481
return resolve(stdout)
8582
}))
86-
console.log('RETURN', versionOutput.trim().split(' ').pop())
87-
return versionOutput.trim().split(' ').pop()
83+
/**
84+
* example output: "Microsoft Edge 124.0.2478.105 unknown"
85+
*/
86+
return versionOutput
87+
/**
88+
* trim the output
89+
*/
90+
.trim()
91+
/**
92+
* split by space, e.g. `[Microsoft, Edge, 124.0.2478.105, unknown]
93+
*/
94+
.split(' ')
95+
/**
96+
* filter for entity that matches the version pattern, e.g. `124.0.2478.105`
97+
*/
98+
.filter((v) => v.match(/\d+\.\d+\.\d+\.\d+/g))
99+
/**
100+
* get the first entity
101+
*/
102+
.pop()
88103
}
89104

90105
export async function fetchVersion (edgeVersion: string) {

0 commit comments

Comments
 (0)