aboutsummaryrefslogtreecommitdiff
path: root/node_modules/write-pkg/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/write-pkg/index.js')
-rw-r--r--node_modules/write-pkg/index.js16
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);
};