Socket
Socket
Sign inDemoInstall

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 2.1.0 to 2.2.0

29

cli.js
#!/usr/bin/env node
import { globbySync } from 'globby'
import fs from 'node:fs'
import { globbySync } from 'globby'
import sortPackageJson from './index.js'
const isCheckFlag = (argument) => argument === '--check' || argument === '-c'
const isHelpFlag = (argument) => argument === '--help' || argument === '-h'
const isVersionFlag = (argument) =>
argument === '--version' || argument === '-v'
const cliArguments = process.argv.slice(2)
const isCheck = cliArguments.some(isCheckFlag)
const isHelp = cliArguments.some(isHelpFlag)
const isVersion = cliArguments.some(isVersionFlag)
if (isHelp) {
console.log(
`Usage: sort-package-json [OPTION...] [FILE...]
Sort npm package.json files. Default: ./package.json
Strings passed as files are parsed as globs.
-c, --check check if FILES are sorted
-h, --help display this help and exit
-v, --version display the version and exit
`,
)
process.exit(0)
}
if (isVersion) {
const packageJsonUrl = new URL('package.json', import.meta.url)
const packageJsonBuffer = fs.readFileSync(packageJsonUrl)
const { version } = JSON.parse(packageJsonBuffer)
console.log(`sort-package-json ${version}`)
process.exit(0)
}
const patterns = cliArguments.filter((argument) => !isCheckFlag(argument))

@@ -12,0 +39,0 @@

2

package.json
{
"name": "sort-package-json",
"version": "2.1.0",
"version": "2.2.0",
"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