update-browserslist-db 1.0.4 → 1.0.7
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.
- package/README.md +2 -2
- package/check-npm-version.js +16 -0
- package/cli.js +1 -0
- package/index.js +13 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Update Browserslist DB
|
|
2
2
|
|
|
3
|
-
<img width="120" height="120" alt="Browserslist logo by Anton
|
|
4
|
-
src="https://
|
|
3
|
+
<img width="120" height="120" alt="Browserslist logo by Anton Popov"
|
|
4
|
+
src="https://browsersl.ist/logo.svg" align="right">
|
|
5
5
|
|
|
6
6
|
CLI tool to update `caniuse-lite` with browsers DB
|
|
7
7
|
from [Browserslist](https://github.com/browserslist/browserslist/) config.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
let { execSync } = require('child_process')
|
|
2
|
+
let pico = require('picocolors')
|
|
3
|
+
|
|
4
|
+
try {
|
|
5
|
+
let version = parseInt(execSync('npm -v'))
|
|
6
|
+
if (version <= 6) {
|
|
7
|
+
process.stderr.write(
|
|
8
|
+
pico.red(
|
|
9
|
+
'Update npm or call ' +
|
|
10
|
+
pico.yellow('npx browserslist@latest --update-db') +
|
|
11
|
+
'\n'
|
|
12
|
+
)
|
|
13
|
+
)
|
|
14
|
+
process.exit(1)
|
|
15
|
+
}
|
|
16
|
+
} catch (e) {}
|
package/cli.js
CHANGED
package/index.js
CHANGED
|
@@ -4,6 +4,18 @@ let pico = require('picocolors')
|
|
|
4
4
|
let path = require('path')
|
|
5
5
|
let fs = require('fs')
|
|
6
6
|
|
|
7
|
+
const DEFAULT_INDENT = ' '
|
|
8
|
+
const INDENT_REGEXP = /^(\s+)[^\s]/m
|
|
9
|
+
|
|
10
|
+
function detectIndent(text) {
|
|
11
|
+
try {
|
|
12
|
+
return INDENT_REGEXP.exec(text)[1] || DEFAULT_INDENT
|
|
13
|
+
} catch (e) {
|
|
14
|
+
/* c8 ignore next 2 */
|
|
15
|
+
return DEFAULT_INDENT
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
7
19
|
function BrowserslistUpdateError(message) {
|
|
8
20
|
this.name = 'BrowserslistUpdateError'
|
|
9
21
|
this.message = message
|
|
@@ -104,7 +116,7 @@ function diffBrowsers(old, current) {
|
|
|
104
116
|
function updateNpmLockfile(lock, latest) {
|
|
105
117
|
let metadata = { latest, versions: [] }
|
|
106
118
|
let content = deletePackage(JSON.parse(lock.content), metadata)
|
|
107
|
-
metadata.content = JSON.stringify(content, null,
|
|
119
|
+
metadata.content = JSON.stringify(content, null, detectIndent(lock.content))
|
|
108
120
|
return metadata
|
|
109
121
|
}
|
|
110
122
|
|