diff options
author | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
commit | bbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch) | |
tree | c58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/write-pkg/index.js | |
parent | 003fb34971cf63466184351b4db5f7c67df4f444 (diff) |
update packages
Diffstat (limited to 'node_modules/write-pkg/index.js')
-rw-r--r-- | node_modules/write-pkg/index.js | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/node_modules/write-pkg/index.js b/node_modules/write-pkg/index.js index 981cc0b54..1c2033af9 100644 --- a/node_modules/write-pkg/index.js +++ b/node_modules/write-pkg/index.js @@ -3,8 +3,6 @@ const path = require('path'); const writeJsonFile = require('write-json-file'); const sortKeys = require('sort-keys'); -const opts = {detectIndent: true}; - const dependencyKeys = new Set([ 'dependencies', 'devDependencies', @@ -26,28 +24,34 @@ function normalize(pkg) { return ret; } -module.exports = (fp, data) => { +module.exports = (fp, data, opts) => { if (typeof fp !== 'string') { + opts = data; data = fp; fp = '.'; } + opts = Object.assign({normalize: true}, opts, {detectIndent: true}); + fp = path.basename(fp) === 'package.json' ? fp : path.join(fp, 'package.json'); - data = normalize(data); + data = opts.normalize ? normalize(data) : data; return writeJsonFile(fp, data, opts); }; -module.exports.sync = (fp, data) => { +module.exports.sync = (fp, data, opts) => { if (typeof fp !== 'string') { + opts = data; data = fp; fp = '.'; } + opts = Object.assign({normalize: true}, opts, {detectIndent: true}); + fp = path.basename(fp) === 'package.json' ? fp : path.join(fp, 'package.json'); - data = normalize(data); + data = opts.normalize ? normalize(data) : data; writeJsonFile.sync(fp, data, opts); }; |