diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-08-14 05:01:11 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-08-14 05:02:09 +0200 |
commit | 363723fc84f7b8477592e0105aeb331ec9a017af (patch) | |
tree | 29f92724f34131bac64d6a318dd7e30612e631c7 /node_modules/write-pkg/index.js | |
parent | 5634e77ad96bfe1818f6b6ee70b7379652e5487f (diff) |
node_modules
Diffstat (limited to 'node_modules/write-pkg/index.js')
-rw-r--r-- | node_modules/write-pkg/index.js | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/node_modules/write-pkg/index.js b/node_modules/write-pkg/index.js index 262fa925a..981cc0b54 100644 --- a/node_modules/write-pkg/index.js +++ b/node_modules/write-pkg/index.js @@ -3,7 +3,7 @@ const path = require('path'); const writeJsonFile = require('write-json-file'); const sortKeys = require('sort-keys'); -const opts = {indent: 2}; +const opts = {detectIndent: true}; const dependencyKeys = new Set([ 'dependencies', @@ -16,7 +16,11 @@ function normalize(pkg) { const ret = {}; for (const key of Object.keys(pkg)) { - ret[key] = dependencyKeys.has(key) ? sortKeys(pkg[key]) : pkg[key]; + if (!dependencyKeys.has(key)) { + ret[key] = pkg[key]; + } else if (Object.keys(pkg[key]).length !== 0) { + ret[key] = sortKeys(pkg[key]); + } } return ret; |