From bbff7403fbf46f9ad92240ac213df8d30ef31b64 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 20 Sep 2018 02:56:13 +0200 Subject: update packages --- node_modules/write-pkg/index.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'node_modules/write-pkg/index.js') 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); }; -- cgit v1.2.3