Skip to content

Commit

Permalink
updated cli to support globs and multiple files
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Inman committed Dec 15, 2015
1 parent f5cb6e7 commit 0966467
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ var options = require("nomnom")
.script("jsonlint")
.options({
file: {
list: true,
position: 0,
help: "file to parse; otherwise uses stdin"
help: "file(s) to parse; otherwise uses stdin"
},
version: {
flag : true,
Expand Down Expand Up @@ -131,12 +132,14 @@ function schemaError (str, err) {
function main (args) {
var source = '';
if (options.file) {
var json = path.normalize(options.file);
source = parse(fs.readFileSync(json, "utf8"));
if (options.inplace) {
fs.writeSync(fs.openSync(json,'w+'), source, 0, "utf8");
} else {
if (! options.quiet) { console.log(source)};
for (var i = 0; i < options.file.length; i++) {
var json = path.normalize(options.file[i]);
source = parse(fs.readFileSync(json, "utf8"));
if (options.inplace) {
fs.writeSync(fs.openSync(json,'w+'), source, 0, "utf8");
} else {
if (! options.quiet) { console.log(source)};
}
}
} else {
var stdin = process.openStdin();
Expand Down

0 comments on commit 0966467

Please sign in to comment.