sort-package-json
Advanced tools
Comparing version 1.32.0 to 1.32.1
24
index.js
#!/usr/bin/env node | ||
const _sortObjectKeys = require('sort-object-keys') | ||
const sortObjectKeys = require('sort-object-keys') | ||
const detectIndent = require('detect-indent') | ||
const detectNewline = require('detect-newline').graceful | ||
const globby = require('globby') | ||
const sortObjectKeys = comp => x => _sortObjectKeys(x, comp) | ||
@@ -13,4 +12,4 @@ const onArray = fn => x => (Array.isArray(x) ? fn(x) : x) | ||
const onObject = fn => x => (isPlainObject(x) ? fn(x) : x) | ||
const sortObjectBy = comparator => onObject(sortObjectKeys(comparator)) | ||
const sortObject = onObject(sortObjectKeys()) | ||
const sortObjectBy = comparator => onObject(x => sortObjectKeys(x, comparator)) | ||
const sortObject = sortObjectBy() | ||
const sortURLObject = sortObjectBy(['type', 'url']) | ||
@@ -164,11 +163,14 @@ const sortAuthorObject = sortObjectBy(['name', 'email', 'url']) | ||
function sortPackageJson(jsonIsh, options = {}) { | ||
return editStringJSON(jsonIsh, json => { | ||
const newJson = sortObjectKeys(options.sortOrder || sortOrder)(json) | ||
return editStringJSON( | ||
jsonIsh, | ||
onObject(json => { | ||
const newJson = sortObjectKeys(json, options.sortOrder || sortOrder) | ||
for (const { key, over } of fields) { | ||
if (over && newJson[key]) newJson[key] = over(newJson[key]) | ||
} | ||
for (const { key, over } of fields) { | ||
if (over && newJson[key]) newJson[key] = over(newJson[key]) | ||
} | ||
return newJson | ||
}) | ||
return newJson | ||
}), | ||
) | ||
} | ||
@@ -175,0 +177,0 @@ |
{ | ||
"name": "sort-package-json", | ||
"version": "1.32.0", | ||
"version": "1.32.1", | ||
"description": "Sort an Object or package.json based on the well-known package.json keys", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
214
12690