sort-package-json
Advanced tools
Comparing version 1.1.3 to 1.2.0
21
index.js
@@ -18,2 +18,21 @@ #!/usr/bin/env node | ||
} | ||
/* b | ||
* pre | * | post | ||
* pre 0 | - | - | ||
* a * + | 0 | - | ||
* post + | + | 0 | ||
*/ | ||
function compareScriptKeys(a, b) { | ||
if (a === b) return 0; | ||
var aScript = a.replace(/^(pre|post)(.)/, '$2'); | ||
var bScript = b.replace(/^(pre|post)(.)/, '$2'); | ||
if (aScript === bScript) { | ||
// pre* is always smaller; post* is always bigger | ||
// Covers: pre* vs. *; pre* vs. post*; * vs. post* | ||
if (a.indexOf('pre') === 0 || b.indexOf('post') === 0) return -1; | ||
// The rest is bigger: * vs. *pre; *post vs. *pre; *post vs. * | ||
return 1; | ||
} | ||
return aScript < bScript ? -1 : 1; | ||
} | ||
sortSubKey('keywords'); | ||
@@ -28,3 +47,3 @@ sortSubKey('homepage'); | ||
sortSubKey('repository', [ 'type', 'url' ]); | ||
sortSubKey('scripts'); | ||
sortSubKey('scripts', compareScriptKeys); | ||
sortSubKey('config'); | ||
@@ -31,0 +50,0 @@ sortSubKey('browser'); |
{ | ||
"name": "sort-package-json", | ||
"version": "1.1.3", | ||
"version": "1.2.0", | ||
"description": "Sort an Object or package.json based on the well-known package.json keys", | ||
@@ -29,2 +29,8 @@ "keywords": [ | ||
}, | ||
"config": { | ||
"ghooks": { | ||
"pre-commit": "npm t", | ||
"commit-msg": "validate-commit-msg" | ||
} | ||
}, | ||
"dependencies": { | ||
@@ -34,5 +40,7 @@ "sort-object-keys": "^1.1.1" | ||
"devDependencies": { | ||
"ghooks": "^1.0.1", | ||
"semantic-release": "^4.3.5", | ||
"travis-after-all": "^1.4.4" | ||
"travis-after-all": "^1.4.4", | ||
"validate-commit-msg": "^1.0.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
6728
117
4