sort-package-json
Advanced tools
Comparing version 1.8.0 to 1.9.0
19
index.js
@@ -129,11 +129,16 @@ #!/usr/bin/env node | ||
module.exports.sortPackageJson = sortPackageJson; | ||
if (require.main === module) { | ||
var fs = require('fs'); | ||
var packageJsonPath = process.cwd() + '/package.json'; | ||
var packageJson = fs.readFileSync(packageJsonPath, 'utf8'); | ||
var sorted = sortPackageJson(packageJson); | ||
if (sorted !== packageJson) { | ||
fs.writeFileSync(packageJsonPath, sorted, 'utf8'); | ||
console.log('Ok, your package.json is sorted'); | ||
} | ||
var filesToProcess = process.argv[2] ? process.argv.slice(2) : [process.cwd() + '/package.json']; | ||
filesToProcess.forEach(function (filePath) { | ||
var packageJson = fs.readFileSync(filePath, 'utf8'); | ||
var sorted = sortPackageJson(packageJson); | ||
if (sorted !== packageJson) { | ||
fs.writeFileSync(filePath, sorted, 'utf8'); | ||
console.log(filePath + ' is sorted!'); | ||
} | ||
}); | ||
} |
{ | ||
"name": "sort-package-json", | ||
"version": "1.8.0", | ||
"version": "1.9.0", | ||
"description": "Sort an Object or package.json based on the well-known package.json keys", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -45,3 +45,3 @@ | ||
$ sort-package-json | ||
Ok, your package.json is sorted | ||
/my-project/package.json is sorted! | ||
$ cat package.json | ||
@@ -58,2 +58,8 @@ { | ||
`sort-package-json` also supports a single argument, telling it where it can find package.json file(s). | ||
```bash | ||
$ sort-package-json packages/*/package.json | ||
``` | ||
### Install | ||
@@ -60,0 +66,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
7638
140
97