update-browserslist-db 1.0.5 → 1.0.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  # Update Browserslist DB
2
2
 
3
- <img width="120" height="120" alt="Browserslist logo by Anton Lovchikov"
4
- src="https://browserslist.github.io/browserslist/logo.svg" align="right">
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.
package/index.js CHANGED
@@ -4,6 +4,8 @@ let pico = require('picocolors')
4
4
  let path = require('path')
5
5
  let fs = require('fs')
6
6
 
7
+ const { detectIndent } = require('./utils')
8
+
7
9
  function BrowserslistUpdateError(message) {
8
10
  this.name = 'BrowserslistUpdateError'
9
11
  this.message = message
@@ -104,7 +106,7 @@ function diffBrowsers(old, current) {
104
106
  function updateNpmLockfile(lock, latest) {
105
107
  let metadata = { latest, versions: [] }
106
108
  let content = deletePackage(JSON.parse(lock.content), metadata)
107
- metadata.content = JSON.stringify(content, null, ' ')
109
+ metadata.content = JSON.stringify(content, null, detectIndent(lock.content))
108
110
  return metadata
109
111
  }
110
112
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "update-browserslist-db",
3
- "version": "1.0.5",
3
+ "version": "1.0.8",
4
4
  "description": "CLI tool to update caniuse-lite to refresh target browsers from Browserslist config",
5
5
  "keywords": [
6
6
  "caniuse",
package/utils.js ADDED
@@ -0,0 +1,9 @@
1
+ const DEFAULT_INDENT = ' '
2
+ const INDENT_REGEXP = /^([ \t]+)[^\s]/m
3
+
4
+ module.exports.detectIndent = text => {
5
+ let match = INDENT_REGEXP.exec(text)
6
+ if (match !== null) return match[1]
7
+ return DEFAULT_INDENT
8
+ }
9
+ module.exports.DEFAULT_INDENT = DEFAULT_INDENT