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

23

cli.js

@@ -10,5 +10,11 @@ #!/usr/bin/env node

argument === '--version' || argument === '-v'
const isQuietFlag = (argument) => argument === '--quiet' || argument === '-q'
const cliArguments = process.argv.slice(2)
const isCheck = cliArguments.some(isCheckFlag)
const isQuiet = cliArguments.some(isQuietFlag)
const stdout = isQuiet ? () => {} : console.log
const stderr = console.error
const isHelp = cliArguments.some(isHelpFlag)

@@ -24,2 +30,3 @@ const isVersion = cliArguments.some(isVersionFlag)

-c, --check check if FILES are sorted
-q, --quiet don't output success messages
-h, --help display this help and exit

@@ -40,3 +47,5 @@ -v, --version display the version and exit

const patterns = cliArguments.filter((argument) => !isCheckFlag(argument))
const patterns = cliArguments.filter(
(argument) => !isCheckFlag(argument) && !isQuietFlag(argument),
)

@@ -50,3 +59,3 @@ if (!patterns.length) {

if (files.length === 0) {
console.log('No matching files.')
stderr('No matching files.')
process.exit(1)

@@ -64,6 +73,6 @@ }

notSortedFiles++
console.log(file)
stdout(file)
} else {
fs.writeFileSync(file, sorted, 'utf8')
console.log(`${file} is sorted!`)
stdout(`${file} is sorted!`)
}

@@ -74,5 +83,5 @@ }

if (isCheck) {
console.log()
stdout()
if (notSortedFiles) {
console.log(
stdout(
notSortedFiles === 1

@@ -83,3 +92,3 @@ ? `${notSortedFiles} of ${files.length} matched file is not sorted.`

} else {
console.log(
stdout(
files.length === 1

@@ -86,0 +95,0 @@ ? `${files.length} matched file is sorted.`

{
"name": "sort-package-json",
"version": "2.2.0",
"version": "2.3.0",
"description": "Sort an Object or package.json based on the well-known package.json keys",

@@ -5,0 +5,0 @@ "keywords": [

@@ -72,2 +72,11 @@ # Sort Package.json

#### `--quiet` flag
In order to silence any successful output, you can run CLI with the `--quiet` flag (or `-q`). This will stop the CLI from outputting if it runs successfully, but will still display errors if they occur. Exit codes will not change.
```bash
$ sort-package-json "**/package.json" --check --quiet
$ sort-package-json "**/package.json" --quiet
```
## API

@@ -74,0 +83,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