Comparing version 1.1.1 to 1.2.0
10
cmd.js
@@ -5,6 +5,12 @@ #!/usr/bin/env node | ||
var path = require('path'); | ||
var detectIndent = require('detect-indent'); | ||
var filename = path.resolve(process.argv[2]); | ||
var json = JSON.parse(fs.readFileSync(filename)); | ||
var file = fs.readFileSync(filename, 'utf8'); | ||
// Try to detect the indentation and fall back to two spaces if unable. | ||
var indent = detectIndent(file).indent || ' '; | ||
var json = JSON.parse(file); | ||
var visit = require('./'); | ||
@@ -14,2 +20,2 @@ | ||
fs.writeFile(filename, JSON.stringify(result, null, ' ')); | ||
fs.writeFile(filename, JSON.stringify(result, null, indent)); |
{ | ||
"name": "sort-json", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "Takes a json-file and return a copy of the same file, but sorted", | ||
"main": "index.js", | ||
"dependencies": {}, | ||
"dependencies": { | ||
"detect-indent": "^4.0.0" | ||
}, | ||
"bin": { | ||
@@ -8,0 +10,0 @@ "sort-json": "./cmd.js" |
@@ -25,2 +25,2 @@ sort-json | ||
For now sort-json takes no other arguments, so the origin file will be overritten by a sorted json file with 2-space indentation. | ||
For now sort-json takes no other arguments, so the original file will be overwritten by a sorted json file, keeping the indentation of the original file. |
Sorry, the diff of this file is not supported yet
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
1992
24
26
1
+ Addeddetect-indent@^4.0.0
+ Addeddetect-indent@4.0.0(transitive)
+ Addedis-finite@1.1.0(transitive)
+ Addedrepeating@2.0.1(transitive)