Skip to content

Commit 9a3f39d

Browse files
committed
fix: don't output color when analyze
1 parent 9fa52f2 commit 9a3f39d

File tree

6 files changed

+46
-14
lines changed

6 files changed

+46
-14
lines changed

lisp/_prepare.el

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,14 @@ and INHERIT-INPUT-METHOD see function `read-string' for more information."
391391
(setq pos (match-end 0)))
392392
(reverse matches))))
393393

394+
;;
395+
;;; Color
396+
397+
(defmacro eask--with-no-color (&rest body)
398+
"Execute forms BODY in when no color output."
399+
(declare (indent 0) (debug t))
400+
`(let ((ansi-inhibit-ansi t)) ,@body))
401+
394402
(defun eask-ansi-codes (s)
395403
"Return a list of ansi codes from S."
396404
(eask-re-seq ansi-color-control-seq-regexp s))

lisp/core/analyze.el

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ information."
6161
(col . ,end-col)
6262
(pos . ,end-pos)))))
6363
(filename . ,filename)
64-
(message . ,msg))
64+
(message . ,msg))
6565
(cl-case level
6666
(`error eask-analyze--errors)
6767
(`warn eask-analyze--warnings)))))
@@ -110,14 +110,18 @@ Argument LEVEL and MSG are data from the debug log signal."
110110
(eask-analyze--pretty-json (json-encode
111111
`((warnings . ,eask-analyze--warnings)
112112
(errors . ,eask-analyze--errors)))))
113-
(eask-msg content))
113+
;; XXX: When printint result, no color allow.
114+
(eask--with-no-color
115+
(eask-msg content)))
114116
(eask-analyze--log ; Plain text
115117
(setq content
116118
(with-temp-buffer
117119
(dolist (msg (reverse eask-analyze--log))
118120
(insert msg "\n"))
119121
(buffer-string)))
120-
(mapc #'eask-msg (reverse eask-analyze--log)))
122+
;; XXX: When printint result, no color allow.
123+
(eask--with-no-color
124+
(mapc #'eask-msg (reverse eask-analyze--log))))
121125
(t
122126
(eask-info "(Checked %s file%s)"
123127
(length checked-files)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`analyze in ./dsl matches snapshot 1`] = `
4+
{
5+
"stderr": "
6+
~/Eask:9:18 Error: ✗ Multiple definition of \`package'
7+
~/Eask:12:55 Error: ✗ Multiple definition of \`website-url'
8+
~/Eask:14:16 Error: ✗ Multiple definition of \`keywords'
9+
~/Eask:17:15 Warning: 💡 Warning regarding duplicate author name, name
10+
~/Eask:20:17 Warning: 💡 Warning regarding duplicate license name, GPLv3
11+
~/Eask:23:29 Error: ✗ Multiple definition of \`package-file'
12+
~/Eask:25:35 Warning: 💡 Pkg-file seems to be missing \`check-pkg.el'
13+
~/Eask:26:35 Error: ✗ Multiple definition of \`package-descriptor'
14+
~/Eask:30:61 Error: ✗ Run-script with the same key name is not allowed: \`test\`
15+
~/Eask:33:13 Error: ✗ Multiple definition of source \`gnu'
16+
~/Eask:35:24 Error: ✗ Unknown package archive \`magic-archive'
17+
~/Eask:37:15 Error: ✗ Invalid archive name \`local'
18+
~/Eask:37:15 Error: ✗ Unknown package archive \`local'
19+
~/Eask:40:20 Error: ✗ Define dependencies with the same name \`emacs'
20+
~/Eask:43:19 Error: ✗ Define dependencies with the same name \`dash'
21+
~/Eask:44:27 Error: ✗ Define dependencies with the same name \`dash' with different version
22+
~/Eask:50:2 Error: ✗ Define dependencies with the same name \`f'
23+
~/Eask:50:2 Error: ✗ Define dependencies with the same name \`f' with different version
24+
",
25+
"stdout": "",
26+
}
27+
`;

test/jest/analyze.test.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,15 @@ describe("analyze", () => {
99
await ctx.runEask("analyze Eask");
1010
});
1111

12-
// TODO: Re-enable this test.
13-
//
14-
// `Bad control character in string literal in JSON`
15-
it.skip("handles json option", async () => {
12+
it("handles json option", async () => {
1613
const { stderr } = await ctx.runEask("analyze --json");
1714
await ctx.runEask("analyze Eask --json");
1815

1916
// try to parse output, errors if not valid
2017
JSON.parse(stderr);
2118
});
2219

23-
// TODO: Re-enable this test.
24-
//
25-
// The match are the same but don't know why it still report errors.
26-
// My best guess is due to the ansi codes (color) differences.
27-
it.skip("matches snapshot", async () => {
20+
it("matches snapshot", async () => {
2821
const res = await ctx.runEask("analyze");
2922
const resClean = res.sanitized().raw();
3023
expect(resClean).toMatchSnapshot();

test/jest/local/Eask

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
;; -*- mode: eask; lexical-binding: t -*-
22

33
(package "mini.pkg.1"
4-
"3.3.4"
4+
"5.5.6"
55
"Minimal test package")
66

77
(website-url "https://github.com/emacs-eask/cli/tree/master/test/fixtures/mini.pkg.1")

test/jest/local/mini.pkg.1.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
;; Author: Shen, Jen-Chieh <[email protected]>
77
;; URL: https://github.com/emacs-eask/cli/tree/master/test/fixtures/mini.pkg.1
8-
;; Version: 3.3.4
8+
;; Version: 5.5.6
99
;; Package-Requires: ((emacs "24.3") (s "1.12.0") (fringe-helper "1.0.1"))
1010
;; Keywords: test local
1111

0 commit comments

Comments
 (0)