summaryrefslogtreecommitdiff
path: root/node_modules/update-browserslist-db/index.js
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2024-05-14 14:05:49 +0800
committerlittleblack111 <littleblack11111@gmail.com>2024-05-14 14:05:49 +0800
commit06823fbf1c2e763a5bf76c3990ca98fbbcd98691 (patch)
tree4280bece3888d12a022093bf1a9cd1b049393602 /node_modules/update-browserslist-db/index.js
parent1368909b3cd552dbb0d12d5863c597f5be46177d (diff)
updated node_modules
Diffstat (limited to 'node_modules/update-browserslist-db/index.js')
-rw-r--r--node_modules/update-browserslist-db/index.js59
1 files changed, 35 insertions, 24 deletions
diff --git a/node_modules/update-browserslist-db/index.js b/node_modules/update-browserslist-db/index.js
index 7fc0d3a4..3272f267 100644
--- a/node_modules/update-browserslist-db/index.js
+++ b/node_modules/update-browserslist-db/index.js
@@ -1,6 +1,6 @@
-let { existsSync, readFileSync, writeFileSync } = require('fs')
-let { execSync } = require('child_process')
-let { join } = require('path')
+let { existsSync, readFileSync, writeFileSync } = require('node:fs')
+let { execSync } = require('node:child_process')
+let { join } = require('node:path')
let escalade = require('escalade/sync')
let pico = require('picocolors')
@@ -17,6 +17,10 @@ function BrowserslistUpdateError(message) {
BrowserslistUpdateError.prototype = Error.prototype
+// Check if HADOOP_HOME is set to determine if this is running in a Hadoop environment
+const IsHadoopExists = !!process.env.HADOOP_HOME
+const yarnCommand = IsHadoopExists ? 'yarnpkg' : 'yarn'
+
/* c8 ignore next 3 */
function defaultPrint(str) {
process.stdout.write(str)
@@ -59,11 +63,12 @@ function detectLockfile() {
function getLatestInfo(lock) {
if (lock.mode === 'yarn') {
if (lock.version === 1) {
- return JSON.parse(execSync('yarnpkg info caniuse-lite --json').toString())
- .data
+ return JSON.parse(
+ execSync(yarnCommand + ' info caniuse-lite --json').toString()
+ ).data
} else {
return JSON.parse(
- execSync('yarnpkg npm info caniuse-lite --json').toString()
+ execSync(yarnCommand + ' npm info caniuse-lite --json').toString()
)
}
}
@@ -209,10 +214,11 @@ function updatePackageManually(print, lock, latest) {
)
writeFileSync(lock.file, lockfileData.content)
- let install = lock.mode === 'yarn' ? 'yarnpkg add -W' : lock.mode + ' install'
+ let install =
+ lock.mode === 'yarn' ? yarnCommand + ' add -W' : lock.mode + ' install'
print(
'Installing new caniuse-lite version\n' +
- pico.yellow('$ ' + install.replace('yarnpkg', 'yarn') + ' caniuse-lite') +
+ pico.yellow('$ ' + install + ' caniuse-lite') +
'\n'
)
try {
@@ -233,21 +239,17 @@ function updatePackageManually(print, lock, latest) {
} /* c8 ignore end */
let del =
- lock.mode === 'yarn' ? 'yarnpkg remove -W' : lock.mode + ' uninstall'
+ lock.mode === 'yarn' ? yarnCommand + ' remove -W' : lock.mode + ' uninstall'
print(
'Cleaning package.json dependencies from caniuse-lite\n' +
- pico.yellow('$ ' + del.replace('yarnpkg', 'yarn') + ' caniuse-lite') +
+ pico.yellow('$ ' + del + ' caniuse-lite') +
'\n'
)
execSync(del + ' caniuse-lite')
}
function updateWith(print, cmd) {
- print(
- 'Updating caniuse-lite version\n' +
- pico.yellow('$ ' + cmd.replace('yarnpkg', 'yarn')) +
- '\n'
- )
+ print('Updating caniuse-lite version\n' + pico.yellow('$ ' + cmd) + '\n')
try {
execSync(cmd)
} catch (e) /* c8 ignore start */ {
@@ -282,7 +284,7 @@ module.exports = function updateDB(print = defaultPrint) {
print('Latest version: ' + pico.bold(pico.green(latest.version)) + '\n')
if (lock.mode === 'yarn' && lock.version !== 1) {
- updateWith(print, 'yarnpkg up -R caniuse-lite')
+ updateWith(print, yarnCommand + ' up -R caniuse-lite')
} else if (lock.mode === 'pnpm') {
updateWith(print, 'pnpm up caniuse-lite')
} else {
@@ -301,15 +303,24 @@ module.exports = function updateDB(print = defaultPrint) {
}
if (listError) {
- print(
- pico.red(
- '\n' +
- listError.stack +
- '\n\n' +
- 'Problem with browser list retrieval.\n' +
- 'Target browser changes won’t be shown.\n'
+ if (listError.message.includes("Cannot find module 'browserslist'")) {
+ print(
+ pico.gray(
+ 'Install `browserslist` to your direct dependencies ' +
+ 'to see target browser changes\n'
+ )
)
- )
+ } else {
+ print(
+ pico.red(
+ '\n' +
+ listError.stack +
+ '\n\n' +
+ 'Problem with browser list retrieval.\n' +
+ 'Target browser changes won’t be shown.\n'
+ )
+ )
+ }
} else {
let changes = diffBrowsers(oldList, newList)
if (changes) {