sort-package-json
Advanced tools
Comparing version 2.12.0 to 2.13.0
21
index.js
@@ -251,6 +251,21 @@ import sortObjectKeys from 'sort-object-keys' | ||
const order = keys.flatMap((key) => | ||
prefixable.has(key) ? [`pre${key}`, key, `post${key}`] : [key], | ||
) | ||
const scriptsKeyMap = new Map() | ||
keys | ||
.flatMap((key) => | ||
prefixable.has(key) ? [`pre${key}`, key, `post${key}`] : [key], | ||
) | ||
.forEach((key) => { | ||
const [prefix] = key.split(':') | ||
const keySet = scriptsKeyMap.has(prefix) | ||
? scriptsKeyMap.get(prefix) | ||
: new Set() | ||
scriptsKeyMap.set(prefix, keySet.add(key)) | ||
}) | ||
const order = [...scriptsKeyMap.values()].flat().reduce((keys, keySet) => { | ||
keys.push(...keySet) | ||
return keys | ||
}, []) | ||
return sortObjectKeys(scripts, order) | ||
@@ -257,0 +272,0 @@ }) |
{ | ||
"name": "sort-package-json", | ||
"version": "2.12.0", | ||
"version": "2.13.0", | ||
"description": "Sort an Object or package.json based on the well-known package.json keys", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
132267
3649