Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sort-package-json

Package Overview
Dependencies
Maintainers
1
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sort-package-json - npm Package Compare versions

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"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc