Skip to content

Commit

Permalink
fix: remove ansi codes from output (denoland#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacasonato authored and CGQAQ committed Sep 13, 2020
1 parent 27f7069 commit b06b99f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ coverage
npm-debug.log*
yarn-debug.log*
yarn-error.log*
/cache

# misc
.DS_Store
Expand Down
22 changes: 12 additions & 10 deletions client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
} from "vscode-languageclient";
import getport from "get-port";
import execa from "execa";
import * as semver from "semver";

import { TreeViewProvider } from "./tree_view_provider";
import { ImportMap } from "../../core/import_map";
Expand Down Expand Up @@ -509,22 +508,25 @@ Executable ${this.denoInfo.executablePath}`;
cancellable: true,
},
(process, cancelToken) => {
// `deno fetch xxx` has been renamed to `deno cache xxx` since Deno v0.40.0
const cmd = semver.gte(this.denoInfo.version.deno, "0.40.0")
? "cache"
: "fetch";
const ps = execa(this.denoInfo.executablePath, [cmd, moduleName], {
// timeout of 2 minute
timeout: 1000 * 60 * 2,
});
const ps = execa(
this.denoInfo.executablePath,
["cache", moduleName],
{
// timeout of 2 minute
timeout: 1000 * 60 * 2,
env: {
NO_COLOR: "1",
},
}
);

const updateProgress: (buf: Buffer) => void = (buf: Buffer) => {
const raw = buf.toString();

const messages = raw.split("\n");

for (let message of messages) {
message = message.replace("[0m[38;5;10mDownload[0m", "").trim();
message = message.replace("Download", "").trim();
if (message) {
process.report({ message });
this.output.appendLine(message);
Expand Down
23 changes: 19 additions & 4 deletions server/src/deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ class Deno {
stdout: "pipe",
stderr: "pipe",
stdin: "pipe",
env: {
NO_COLOR: "1",
},
});

const formattedCode = (await new Promise((resolve, reject) => {
Expand Down Expand Up @@ -118,6 +121,10 @@ class Deno {
["lint", "--unstable", "--rules"],
{
stdout: "pipe",

env: {
NO_COLOR: "1",
},
}
);

Expand Down Expand Up @@ -150,6 +157,9 @@ class Deno {
{
stdin: "pipe",
stderr: "pipe",
env: {
NO_COLOR: "1",
},
}
);

Expand All @@ -172,10 +182,15 @@ class Deno {
return denoPath;
}
private async getDenoVersion(): Promise<Version | undefined> {
const { stdout, stderr } = await execa(this.executablePath as string, [
"eval",
"console.log(JSON.stringify(Deno.version))",
]);
const { stdout, stderr } = await execa(
this.executablePath as string,
["eval", "console.log(JSON.stringify(Deno.version))"],
{
env: {
NO_COLOR: "1",
},
}
);

if (stderr) {
return;
Expand Down

0 comments on commit b06b99f

Please sign in to comment.