Skip to content

Commit 4f7553e

Browse files
committed
Print empty json when no errors
1 parent 2a64cdb commit 4f7553e

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

lisp/core/analyze.el

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,15 @@ Argument LEVEL and MSG are data from the debug log signal."
114114

115115
;; Print result
116116
(eask-msg "")
117-
(cond ((and (eask-json-p) ; JSON format
118-
(or eask-analyze--warnings eask-analyze--errors))
119-
(setq content
120-
(eask-analyze--pretty-json (json-encode
121-
`((warnings . ,eask-analyze--warnings)
122-
(errors . ,eask-analyze--errors)))))
117+
(cond ((eask-json-p) ; JSON format
118+
(when (or eask-analyze--warnings eask-analyze--errors)
119+
(setq content
120+
(eask-analyze--pretty-json (json-encode
121+
`((warnings . ,eask-analyze--warnings)
122+
(errors . ,eask-analyze--errors))))))
123123
;; XXX: When printing the result, no color allow.
124124
(eask--with-no-color
125-
(eask-stdout content)))
125+
(eask-stdout (or content "{}"))))
126126
(eask-analyze--log ; Plain text
127127
(setq content
128128
(with-temp-buffer

test/jest/analyze.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ const { TestContext } = require("./helpers");
22

33
/**
44
* Clean output and attempt to parse as JSON.
5+
* Does not accept empty strings as JSON.
56
* Throws if failing.
67
* @param {string} s
78
* @returns {object} the parsed JSON.
89
*/
910
function tryJSON(s) {
10-
return JSON.parse(s.trim() || "{}");
11+
return JSON.parse(s.trim());
1112
}
1213

1314
describe("analyze", () => {

0 commit comments

Comments
 (0)