sort-package-json
Advanced tools
Comparing version 1.38.3 to 1.39.0
@@ -32,3 +32,3 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
packageJson: T, | ||
options?: sortPackageJson.Options | ||
options?: sortPackageJson.Options, | ||
): T | ||
@@ -35,0 +35,0 @@ |
16
index.js
@@ -18,3 +18,15 @@ const sortObjectKeys = require('sort-object-keys') | ||
const onObject = fn => x => (isPlainObject(x) ? fn(x) : x) | ||
const sortObjectBy = comparator => onObject(x => sortObjectKeys(x, comparator)) | ||
const sortObjectBy = (comparator, deep) => { | ||
const over = onObject(object => { | ||
object = sortObjectKeys(object, comparator) | ||
if (deep) { | ||
for (const [key, value] of Object.entries(object)) { | ||
object[key] = over(value) | ||
} | ||
} | ||
return object | ||
}) | ||
return over | ||
} | ||
const sortObject = sortObjectBy() | ||
@@ -231,2 +243,4 @@ const sortURLObject = sortObjectBy(['type', 'url']) | ||
{ key: 'peerDependencies', over: sortObject }, | ||
// TODO: only sort depth = 2 | ||
{ key: 'peerDependenciesMeta', over: sortObjectBy(undefined, true) }, | ||
{ key: 'optionalDependencies', over: sortObject }, | ||
@@ -233,0 +247,0 @@ { key: 'bundledDependencies', over: uniqAndSortArray }, |
{ | ||
"name": "sort-package-json", | ||
"version": "1.38.3", | ||
"version": "1.39.0", | ||
"description": "Sort an Object or package.json based on the well-known package.json keys", | ||
@@ -37,3 +37,3 @@ "keywords": [ | ||
"hooks": { | ||
"pre-commit": "npm t", | ||
"pre-commit": "npm t && lint-staged", | ||
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS" | ||
@@ -47,2 +47,16 @@ } | ||
}, | ||
"lint-staged": { | ||
"*.js": [ | ||
"eslint --fix", | ||
"git add" | ||
], | ||
"*.ts": [ | ||
"prettier --write", | ||
"git add" | ||
], | ||
"package.json": [ | ||
"node cli.js", | ||
"git add" | ||
] | ||
}, | ||
"prettier": { | ||
@@ -85,8 +99,9 @@ "semi": false, | ||
"husky": "^4.0.2", | ||
"lint-staged": "^9.5.0", | ||
"make-dir": "3.0.0", | ||
"nyc": "^15.0.0", | ||
"prettier": "^1.19.1", | ||
"semantic-release": "16.0.0", | ||
"semantic-release": "16.0.1", | ||
"tempy": "0.3.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20142
385
20