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.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": [

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