summaryrefslogtreecommitdiff
path: root/node_modules/update-browserslist-db
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/update-browserslist-db')
-rw-r--r--node_modules/update-browserslist-db/check-npm-version.js4
-rwxr-xr-xnode_modules/update-browserslist-db/cli.js4
-rw-r--r--node_modules/update-browserslist-db/index.js59
-rw-r--r--node_modules/update-browserslist-db/package.json4
-rw-r--r--node_modules/update-browserslist-db/utils.js9
5 files changed, 47 insertions, 33 deletions
diff --git a/node_modules/update-browserslist-db/check-npm-version.js b/node_modules/update-browserslist-db/check-npm-version.js
index 5a37592b..91f14019 100644
--- a/node_modules/update-browserslist-db/check-npm-version.js
+++ b/node_modules/update-browserslist-db/check-npm-version.js
@@ -1,4 +1,4 @@
-let { execSync } = require('child_process')
+let { execSync } = require('node:child_process')
let pico = require('picocolors')
try {
@@ -7,7 +7,7 @@ try {
process.stderr.write(
pico.red(
'Update npm or call ' +
- pico.yellow('npx update-browserslist-db@latest') +
+ pico.yellow('npx browserslist@latest --update-db') +
'\n'
)
)
diff --git a/node_modules/update-browserslist-db/cli.js b/node_modules/update-browserslist-db/cli.js
index 1388e94d..1884050b 100755
--- a/node_modules/update-browserslist-db/cli.js
+++ b/node_modules/update-browserslist-db/cli.js
@@ -1,7 +1,7 @@
#!/usr/bin/env node
-let { readFileSync } = require('fs')
-let { join } = require('path')
+let { readFileSync } = require('node:fs')
+let { join } = require('node:path')
require('./check-npm-version')
let updateDb = require('./')
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) {
diff --git a/node_modules/update-browserslist-db/package.json b/node_modules/update-browserslist-db/package.json
index f1997a18..6ff42192 100644
--- a/node_modules/update-browserslist-db/package.json
+++ b/node_modules/update-browserslist-db/package.json
@@ -1,6 +1,6 @@
{
"name": "update-browserslist-db",
- "version": "1.0.13",
+ "version": "1.0.15",
"description": "CLI tool to update caniuse-lite to refresh target browsers from Browserslist config",
"keywords": [
"caniuse",
@@ -30,7 +30,7 @@
"./package.json": "./package.json"
},
"dependencies": {
- "escalade": "^3.1.1",
+ "escalade": "^3.1.2",
"picocolors": "^1.0.0"
},
"peerDependencies": {
diff --git a/node_modules/update-browserslist-db/utils.js b/node_modules/update-browserslist-db/utils.js
index d3ac914d..355eaca4 100644
--- a/node_modules/update-browserslist-db/utils.js
+++ b/node_modules/update-browserslist-db/utils.js
@@ -1,10 +1,13 @@
-const { EOL } = require('os')
+const { EOL } = require('node:os')
const getFirstRegexpMatchOrDefault = (text, regexp, defaultValue) => {
regexp.lastIndex = 0 // https://stackoverflow.com/a/11477448/4536543
let match = regexp.exec(text)
- if (match !== null) return match[1]
- return defaultValue
+ if (match !== null) {
+ return match[1]
+ } else {
+ return defaultValue
+ }
}
const DEFAULT_INDENT = ' '