Skip to content

Commit

Permalink
♻️ Use strip-ansi instead of a custom regex
Browse files Browse the repository at this point in the history
Also use the esModuleInterop flag to be able to import strip-ansi
  • Loading branch information
numaru committed Jun 4, 2022
1 parent 0fcd0e9 commit ffaab04
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 137 deletions.
175 changes: 52 additions & 123 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"tslib": "^1.9.3",
"vscode-test-adapter-api": "^1.2.0",
"vscode-test-adapter-util": "^0.5.1",
"xml2js": "^0.4.19"
"xml2js": "^0.4.19",
"strip-ansi": "^6.0.0"
},
"devDependencies": {
"@types/glob": "^7.1.3",
Expand Down
21 changes: 11 additions & 10 deletions src/adapter.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import * as child_process from 'child_process';
import * as async_mutex from 'async-mutex';
import * as tree_kill from 'tree-kill';
import * as path from 'path';
import * as fs from 'fs';
import * as yaml from 'js-yaml';
import * as xml2js from 'xml2js';
import * as vscode from 'vscode';
import child_process from 'child_process';
import async_mutex from 'async-mutex';
import tree_kill from 'tree-kill';
import path from 'path';
import fs from 'fs';
import yaml from 'js-yaml';
import xml2js from 'xml2js';
import vscode from 'vscode';
import stripAnsi from 'strip-ansi';
import {
TestAdapter,
TestLoadStartedEvent,
Expand Down Expand Up @@ -373,8 +374,8 @@ export class CeedlingAdapter implements TestAdapter {
const ansiEscapeSequencesRemoved = this.getConfiguration().get<boolean>('ansiEscapeSequencesRemoved', true);
if (ansiEscapeSequencesRemoved) {
// Remove ansi colors from the outputs
stdout = stdout.replace(/\u001B\[[;\d]*m/g, "");
stderr = stderr.replace(/\u001B\[[;\d]*m/g, "");
stdout = stripAnsi(stdout);
stderr = stripAnsi(stderr);
}
resolve({ error, stdout, stderr });
},
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as vscode from 'vscode';
import vscode from 'vscode';
import { TestHub, testExplorerExtensionId } from 'vscode-test-adapter-api';
import { TestAdapterRegistrar } from 'vscode-test-adapter-util';
import { CeedlingAdapter } from './adapter';
Expand Down
2 changes: 1 addition & 1 deletion src/problemMatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
Uri,
languages
} from 'vscode';
import * as path from 'path';
import path from 'path';

export interface ProblemMatchingPattern {
scanStdout: boolean;
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"noImplicitReturns": true,
"noUnusedLocals": true,
"removeComments": true,
"skipLibCheck": true
"skipLibCheck": true,
"esModuleInterop": true,
},
"include": [
"src/**/*.ts"
Expand Down

0 comments on commit ffaab04

Please sign in to comment.