update-browserslist-db 1.0.13 → 1.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- let { execSync } = require('child_process')
1
+ let { execSync } = require('node:child_process')
2
2
  let pico = require('picocolors')
3
3
 
4
4
  try {
@@ -7,7 +7,7 @@ try {
7
7
  process.stderr.write(
8
8
  pico.red(
9
9
  'Update npm or call ' +
10
- pico.yellow('npx update-browserslist-db@latest') +
10
+ pico.yellow('npx browserslist@latest --update-db') +
11
11
  '\n'
12
12
  )
13
13
  )
package/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- let { readFileSync } = require('fs')
4
- let { join } = require('path')
3
+ let { readFileSync } = require('node:fs')
4
+ let { join } = require('node:path')
5
5
 
6
6
  require('./check-npm-version')
7
7
  let updateDb = require('./')
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
- let { existsSync, readFileSync, writeFileSync } = require('fs')
2
- let { execSync } = require('child_process')
3
- let { join } = require('path')
1
+ let { existsSync, readFileSync, writeFileSync } = require('node:fs')
2
+ let { execSync } = require('node:child_process')
3
+ let { join } = require('node:path')
4
4
  let escalade = require('escalade/sync')
5
5
  let pico = require('picocolors')
6
6
 
@@ -17,6 +17,10 @@ function BrowserslistUpdateError(message) {
17
17
 
18
18
  BrowserslistUpdateError.prototype = Error.prototype
19
19
 
20
+ // Check if HADOOP_HOME is set to determine if this is running in a Hadoop environment
21
+ const IsHadoopExists = !! process.env.HADOOP_HOME
22
+ const yarnCommand = IsHadoopExists ? 'yarnpkg' : 'yarn'
23
+
20
24
  /* c8 ignore next 3 */
21
25
  function defaultPrint(str) {
22
26
  process.stdout.write(str)
@@ -59,12 +63,9 @@ function detectLockfile() {
59
63
  function getLatestInfo(lock) {
60
64
  if (lock.mode === 'yarn') {
61
65
  if (lock.version === 1) {
62
- return JSON.parse(execSync('yarnpkg info caniuse-lite --json').toString())
63
- .data
66
+ return JSON.parse(execSync(yarnCommand + ' info caniuse-lite --json').toString()).data
64
67
  } else {
65
- return JSON.parse(
66
- execSync('yarnpkg npm info caniuse-lite --json').toString()
67
- )
68
+ return JSON.parse(execSync(yarnCommand + ' npm info caniuse-lite --json').toString())
68
69
  }
69
70
  }
70
71
  if (lock.mode === 'pnpm') {
@@ -209,10 +210,10 @@ function updatePackageManually(print, lock, latest) {
209
210
  )
210
211
  writeFileSync(lock.file, lockfileData.content)
211
212
 
212
- let install = lock.mode === 'yarn' ? 'yarnpkg add -W' : lock.mode + ' install'
213
+ let install = lock.mode === 'yarn' ? yarnCommand + ' add -W' : lock.mode + ' install'
213
214
  print(
214
215
  'Installing new caniuse-lite version\n' +
215
- pico.yellow('$ ' + install.replace('yarnpkg', 'yarn') + ' caniuse-lite') +
216
+ pico.yellow('$ ' + install + ' caniuse-lite') +
216
217
  '\n'
217
218
  )
218
219
  try {
@@ -232,22 +233,17 @@ function updatePackageManually(print, lock, latest) {
232
233
  process.exit(1)
233
234
  } /* c8 ignore end */
234
235
 
235
- let del =
236
- lock.mode === 'yarn' ? 'yarnpkg remove -W' : lock.mode + ' uninstall'
236
+ let del = lock.mode === 'yarn' ? yarnCommand + ' remove -W' : lock.mode + ' uninstall'
237
237
  print(
238
238
  'Cleaning package.json dependencies from caniuse-lite\n' +
239
- pico.yellow('$ ' + del.replace('yarnpkg', 'yarn') + ' caniuse-lite') +
239
+ pico.yellow('$ ' + del + ' caniuse-lite') +
240
240
  '\n'
241
241
  )
242
242
  execSync(del + ' caniuse-lite')
243
243
  }
244
244
 
245
245
  function updateWith(print, cmd) {
246
- print(
247
- 'Updating caniuse-lite version\n' +
248
- pico.yellow('$ ' + cmd.replace('yarnpkg', 'yarn')) +
249
- '\n'
250
- )
246
+ print( 'Updating caniuse-lite version\n' + pico.yellow('$ ' + cmd) + '\n' )
251
247
  try {
252
248
  execSync(cmd)
253
249
  } catch (e) /* c8 ignore start */ {
@@ -282,7 +278,7 @@ module.exports = function updateDB(print = defaultPrint) {
282
278
  print('Latest version: ' + pico.bold(pico.green(latest.version)) + '\n')
283
279
 
284
280
  if (lock.mode === 'yarn' && lock.version !== 1) {
285
- updateWith(print, 'yarnpkg up -R caniuse-lite')
281
+ updateWith(print, yarnCommand + ' up -R caniuse-lite')
286
282
  } else if (lock.mode === 'pnpm') {
287
283
  updateWith(print, 'pnpm up caniuse-lite')
288
284
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "update-browserslist-db",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "CLI tool to update caniuse-lite to refresh target browsers from Browserslist config",
5
5
  "keywords": [
6
6
  "caniuse",
@@ -30,7 +30,7 @@
30
30
  "./package.json": "./package.json"
31
31
  },
32
32
  "dependencies": {
33
- "escalade": "^3.1.1",
33
+ "escalade": "^3.1.2",
34
34
  "picocolors": "^1.0.0"
35
35
  },
36
36
  "peerDependencies": {
package/utils.js CHANGED
@@ -1,10 +1,13 @@
1
- const { EOL } = require('os')
1
+ const { EOL } = require('node:os')
2
2
 
3
3
  const getFirstRegexpMatchOrDefault = (text, regexp, defaultValue) => {
4
4
  regexp.lastIndex = 0 // https://stackoverflow.com/a/11477448/4536543
5
5
  let match = regexp.exec(text)
6
- if (match !== null) return match[1]
7
- return defaultValue
6
+ if (match !== null) {
7
+ return match[1]
8
+ } else {
9
+ return defaultValue
10
+ }
8
11
  }
9
12
 
10
13
  const DEFAULT_INDENT = ' '