Skip to content

Commit 2fbbf1b

Browse files
committed
fix: avoid accidentally trigerring the installedBrowsers getter
fixes vuejs#5286
1 parent ede7da2 commit 2fbbf1b

File tree

2 files changed

+42
-38
lines changed

2 files changed

+42
-38
lines changed

packages/@vue/cli-shared-utils/index.js

+7
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,10 @@
1919
exports.chalk = require('chalk')
2020
exports.execa = require('execa')
2121
exports.semver = require('semver')
22+
23+
Object.defineProperty(exports, 'installedBrowsers', {
24+
enumerable: true,
25+
get () {
26+
return exports.getInstalledBrowsers()
27+
}
28+
})

packages/@vue/cli-shared-utils/lib/env.js

+35-38
Original file line numberDiff line numberDiff line change
@@ -178,44 +178,41 @@ function getMacAppVersion (bundleIdentifier) {
178178
}
179179
}
180180

181-
Object.defineProperty(exports, 'installedBrowsers', {
182-
enumerable: true,
183-
get () {
184-
if (hasCheckedBrowsers) {
185-
return browsers
186-
}
187-
hasCheckedBrowsers = true
188-
189-
if (exports.isLinux) {
190-
browsers.chrome = getLinuxAppVersion('google-chrome')
191-
browsers.firefox = getLinuxAppVersion('firefox')
192-
} else if (exports.isMacintosh) {
193-
browsers.chrome = getMacAppVersion('com.google.Chrome')
194-
browsers.firefox = getMacAppVersion('org.mozilla.firefox')
195-
} else if (exports.isWindows) {
196-
// get chrome stable version
197-
// https://stackoverflow.com/a/51773107/2302258
198-
const chromeQueryResult = tryRun(
199-
'reg query "HKLM\\Software\\Google\\Update\\Clients\\{8A69D345-D564-463c-AFF1-A69D9E530F96}" /v pv /reg:32'
200-
) || tryRun(
201-
'reg query "HKCU\\Software\\Google\\Update\\Clients\\{8A69D345-D564-463c-AFF1-A69D9E530F96}" /v pv /reg:32'
202-
)
203-
if (chromeQueryResult) {
204-
const matched = chromeQueryResult.match(/REG_SZ\s+(\S*)$/)
205-
browsers.chrome = matched && matched[1]
206-
}
207-
208-
// get firefox version
209-
// https://community.spiceworks.com/topic/111518-how-to-determine-version-of-installed-firefox-in-windows-batchscript
210-
const ffQueryResult = tryRun(
211-
'reg query "HKLM\\Software\\Mozilla\\Mozilla Firefox" /v CurrentVersion'
212-
)
213-
if (ffQueryResult) {
214-
const matched = ffQueryResult.match(/REG_SZ\s+(\S*)$/)
215-
browsers.firefox = matched && matched[1]
216-
}
181+
exports.getInstalledBrowsers = () => {
182+
if (hasCheckedBrowsers) {
183+
return browsers
184+
}
185+
hasCheckedBrowsers = true
186+
187+
if (exports.isLinux) {
188+
browsers.chrome = getLinuxAppVersion('google-chrome')
189+
browsers.firefox = getLinuxAppVersion('firefox')
190+
} else if (exports.isMacintosh) {
191+
browsers.chrome = getMacAppVersion('com.google.Chrome')
192+
browsers.firefox = getMacAppVersion('org.mozilla.firefox')
193+
} else if (exports.isWindows) {
194+
// get chrome stable version
195+
// https://stackoverflow.com/a/51773107/2302258
196+
const chromeQueryResult = tryRun(
197+
'reg query "HKLM\\Software\\Google\\Update\\Clients\\{8A69D345-D564-463c-AFF1-A69D9E530F96}" /v pv /reg:32'
198+
) || tryRun(
199+
'reg query "HKCU\\Software\\Google\\Update\\Clients\\{8A69D345-D564-463c-AFF1-A69D9E530F96}" /v pv /reg:32'
200+
)
201+
if (chromeQueryResult) {
202+
const matched = chromeQueryResult.match(/REG_SZ\s+(\S*)$/)
203+
browsers.chrome = matched && matched[1]
217204
}
218205

219-
return browsers
206+
// get firefox version
207+
// https://community.spiceworks.com/topic/111518-how-to-determine-version-of-installed-firefox-in-windows-batchscript
208+
const ffQueryResult = tryRun(
209+
'reg query "HKLM\\Software\\Mozilla\\Mozilla Firefox" /v CurrentVersion'
210+
)
211+
if (ffQueryResult) {
212+
const matched = ffQueryResult.match(/REG_SZ\s+(\S*)$/)
213+
browsers.firefox = matched && matched[1]
214+
}
220215
}
221-
})
216+
217+
return browsers
218+
}

0 commit comments

Comments
 (0)