|
1 | 1 | import * as cp from "child_process"
|
2 | 2 | import Bundler from "parcel-bundler"
|
3 | 3 | import * as path from "path"
|
| 4 | +import { onLine } from "../../src/node/util" |
4 | 5 |
|
5 | 6 | async function main(): Promise<void> {
|
6 | 7 | try {
|
@@ -101,38 +102,6 @@ class Watcher {
|
101 | 102 | plugin.stderr.on("data", (d) => process.stderr.write(d))
|
102 | 103 | }
|
103 | 104 |
|
104 |
| - // From https://github.com/chalk/ansi-regex |
105 |
| - const pattern = [ |
106 |
| - "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)", |
107 |
| - "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))", |
108 |
| - ].join("|") |
109 |
| - const re = new RegExp(pattern, "g") |
110 |
| - |
111 |
| - /** |
112 |
| - * Split stdout on newlines and strip ANSI codes. |
113 |
| - */ |
114 |
| - const onLine = (proc: cp.ChildProcess, callback: (strippedLine: string, originalLine: string) => void): void => { |
115 |
| - let buffer = "" |
116 |
| - if (!proc.stdout) { |
117 |
| - throw new Error("no stdout") |
118 |
| - } |
119 |
| - proc.stdout.setEncoding("utf8") |
120 |
| - proc.stdout.on("data", (d) => { |
121 |
| - const data = buffer + d |
122 |
| - const split = data.split("\n") |
123 |
| - const last = split.length - 1 |
124 |
| - |
125 |
| - for (let i = 0; i < last; ++i) { |
126 |
| - callback(split[i].replace(re, ""), split[i]) |
127 |
| - } |
128 |
| - |
129 |
| - // The last item will either be an empty string (the data ended with a |
130 |
| - // newline) or a partial line (did not end with a newline) and we must |
131 |
| - // wait to parse it until we get a full line. |
132 |
| - buffer = split[last] |
133 |
| - }) |
134 |
| - } |
135 |
| - |
136 | 105 | let startingVscode = false
|
137 | 106 | let startedVscode = false
|
138 | 107 | onLine(vscode, (line, original) => {
|
|
0 commit comments