-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
32 lines (26 loc) · 835 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const { exec } = require('child_process')
const { promisify } = require('util')
const execp = promisify(exec)
function getIEVersion() {
const cmd = 'reg query "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Internet Explorer" /v svcVersion'
if (process.platform !== 'win32') {
throw new Error('This module only works on Windows')
}
return execp(cmd)
.then(({ stdout } = {}) => {
if (stdout) {
const result = stdout
.trim()
.replace(/\r?\n|\r/g, '')
.match(/.* ((\d{1,6}\.?){3,5})$/)
if (result && result.length > 1) {
return result[1]
} else {
throw new Error('Could not determine IE version from output')
}
} else {
throw new Error('reg query did not return data')
}
})
}
module.exports = { getIEVersion }