summaryrefslogtreecommitdiff
path: root/tools/node_modules/eslint/node_modules/update-browserslist-db/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/node_modules/eslint/node_modules/update-browserslist-db/index.js')
-rw-r--r--tools/node_modules/eslint/node_modules/update-browserslist-db/index.js59
1 files changed, 31 insertions, 28 deletions
diff --git a/tools/node_modules/eslint/node_modules/update-browserslist-db/index.js b/tools/node_modules/eslint/node_modules/update-browserslist-db/index.js
index ad7fed637d..464f74da43 100644
--- a/tools/node_modules/eslint/node_modules/update-browserslist-db/index.js
+++ b/tools/node_modules/eslint/node_modules/update-browserslist-db/index.js
@@ -1,8 +1,8 @@
-let childProcess = require('child_process')
+let { writeFileSync, readFileSync, existsSync } = require('fs')
+let { execSync } = require('child_process')
+let { join } = require('path')
let escalade = require('escalade/sync')
let pico = require('picocolors')
-let path = require('path')
-let fs = require('fs')
const { detectIndent, detectEOL } = require('./utils')
@@ -34,21 +34,21 @@ function detectLockfile() {
)
}
- let lockfileNpm = path.join(packageDir, 'package-lock.json')
- let lockfileShrinkwrap = path.join(packageDir, 'npm-shrinkwrap.json')
- let lockfileYarn = path.join(packageDir, 'yarn.lock')
- let lockfilePnpm = path.join(packageDir, 'pnpm-lock.yaml')
+ let lockfileNpm = join(packageDir, 'package-lock.json')
+ let lockfileShrinkwrap = join(packageDir, 'npm-shrinkwrap.json')
+ let lockfileYarn = join(packageDir, 'yarn.lock')
+ let lockfilePnpm = join(packageDir, 'pnpm-lock.yaml')
- if (fs.existsSync(lockfilePnpm)) {
+ if (existsSync(lockfilePnpm)) {
return { mode: 'pnpm', file: lockfilePnpm }
- } else if (fs.existsSync(lockfileNpm)) {
+ } else if (existsSync(lockfileNpm)) {
return { mode: 'npm', file: lockfileNpm }
- } else if (fs.existsSync(lockfileYarn)) {
+ } else if (existsSync(lockfileYarn)) {
let lock = { mode: 'yarn', file: lockfileYarn }
- lock.content = fs.readFileSync(lock.file).toString()
+ lock.content = readFileSync(lock.file).toString()
lock.version = /# yarn lockfile v1/.test(lock.content) ? 1 : 2
return lock
- } else if (fs.existsSync(lockfileShrinkwrap)) {
+ } else if (existsSync(lockfileShrinkwrap)) {
return { mode: 'npm', file: lockfileShrinkwrap }
}
throw new BrowserslistUpdateError(
@@ -59,23 +59,18 @@ function detectLockfile() {
function getLatestInfo(lock) {
if (lock.mode === 'yarn') {
if (lock.version === 1) {
- return JSON.parse(
- childProcess.execSync('yarn info caniuse-lite --json').toString()
- ).data
+ return JSON.parse(execSync('yarn info caniuse-lite --json').toString())
+ .data
} else {
return JSON.parse(
- childProcess.execSync('yarn npm info caniuse-lite --json').toString()
+ execSync('yarn npm info caniuse-lite --json').toString()
)
}
}
if (lock.mode === 'pnpm') {
- return JSON.parse(
- childProcess.execSync('pnpm info caniuse-lite --json').toString()
- )
+ return JSON.parse(execSync('pnpm info caniuse-lite --json').toString())
}
- return JSON.parse(
- childProcess.execSync('npm show caniuse-lite --json').toString()
- )
+ return JSON.parse(execSync('npm show caniuse-lite --json').toString())
}
function getBrowsers() {
@@ -126,6 +121,14 @@ function deletePackage(node, metadata) {
node.dependencies[i] = deletePackage(node.dependencies[i], metadata)
}
}
+ if (node.packages) {
+ for (let path in node.packages) {
+ if (path.endsWith('/caniuse-lite')) {
+ metadata.versions[node.packages[path].version] = true
+ delete node.packages[path]
+ }
+ }
+ }
return node
}
@@ -165,7 +168,7 @@ function updateYarnLockfile(lock, latest) {
}
function updateLockfile(lock, latest) {
- if (!lock.content) lock.content = fs.readFileSync(lock.file).toString()
+ if (!lock.content) lock.content = readFileSync(lock.file).toString()
let updatedLockFile
if (lock.mode === 'yarn') {
@@ -186,7 +189,7 @@ function updatePackageManually(print, lock, latest) {
if (caniuseVersions.length === 1 && caniuseVersions[0] === latest.version) {
print(
'Installed version: ' +
- pico.bold(pico.green(latest.version)) +
+ pico.bold(pico.green(caniuseVersions[0])) +
'\n' +
pico.bold(pico.green('caniuse-lite is up to date')) +
'\n'
@@ -204,7 +207,7 @@ function updatePackageManually(print, lock, latest) {
'\n' +
'Removing old caniuse-lite from lock file\n'
)
- fs.writeFileSync(lock.file, lockfileData.content)
+ writeFileSync(lock.file, lockfileData.content)
let install = lock.mode === 'yarn' ? 'yarn add -W' : lock.mode + ' install'
print(
@@ -213,7 +216,7 @@ function updatePackageManually(print, lock, latest) {
'\n'
)
try {
- childProcess.execSync(install + ' caniuse-lite')
+ execSync(install + ' caniuse-lite')
} catch (e) /* c8 ignore start */ {
print(
pico.red(
@@ -235,13 +238,13 @@ function updatePackageManually(print, lock, latest) {
pico.yellow('$ ' + del + ' caniuse-lite') +
'\n'
)
- childProcess.execSync(del + ' caniuse-lite')
+ execSync(del + ' caniuse-lite')
}
function updateWith(print, cmd) {
print('Updating caniuse-lite version\n' + pico.yellow('$ ' + cmd) + '\n')
try {
- childProcess.execSync(cmd)
+ execSync(cmd)
} catch (e) /* c8 ignore start */ {
print(pico.red(e.stdout.toString()))
print(