Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--quiet + STDIN never gives errors and exits with exitcode 0 #41

Open
petski opened this issue Nov 28, 2013 · 1 comment
Open

--quiet + STDIN never gives errors and exits with exitcode 0 #41

petski opened this issue Nov 28, 2013 · 1 comment

Comments

@petski
Copy link

petski commented Nov 28, 2013

Quiet + file:

$ echo "{ 'single-quoted': 'thus-bad-json' }" > /tmp/bad.json
$ jsonlint -c -q /tmp/bad.json ; echo $?
/tmp/bad.json: line 1, col 1, found: 'INVALID' - expected: 'STRING', '}'.
1

Quiet + STDIN:

$ echo "{ 'single-quoted': 'thus-bad-json' }" | jsonlint -c -q -; echo $?
0

Resolved with following patch:

--- /usr/local/bin/jsonlint.orig        2013-11-28 11:43:41.000000000 +0100
+++ /usr/local/bin/jsonlint     2013-11-28 11:44:48.000000000 +0100
@@ -147,7 +147,8 @@ function main (args) {
       source += chunk.toString('utf8');
     });
     stdin.on('end', function () {
-      if (! options.quiet) {console.log(parse(source))};
+      source = parse(source);
+      if (! options.quiet) {console.log(source)};
     });
   }
 }

Behaviour after patch:

$ echo "{ 'single-quoted': 'thus-bad-json' }" | jsonlint -c -q -; echo $?
line 1, col 1, found: 'INVALID' - expected: 'STRING', '}'.
1
@prantlf
Copy link

prantlf commented May 19, 2019

I needed some bugfixes and extensions to jsonlint and did them in my fork. I released the changes as a new NPM module @prantlf/jsonlint. A proper error output despite the "quiet mode" and reading data from stdin was one of them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants