Skip to content

Commit 8c0bff8

Browse files
committed
wip
1 parent 40e37c9 commit 8c0bff8

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

integration/helpers/stream.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,22 @@ export async function match(
77
/** Measured in ms */
88
timeout?: number;
99
} = {},
10-
): Promise<string> {
10+
): Promise<RegExpMatchArray> {
1111
// Prepare error outside of promise so that stacktrace points to caller of `matchLine`
12-
const timeout = new Error(`Timed out - Could not find pattern: ${pattern}`);
13-
return new Promise<string>(async (resolve, reject) => {
14-
setTimeout(() => reject(timeout), options.timeout ?? 10_000);
12+
const timeoutError = new Error(
13+
`Timed out - Could not find pattern: ${pattern}`,
14+
);
15+
return new Promise(async (resolve, reject) => {
16+
const timeout = setTimeout(
17+
() => reject(timeoutError),
18+
options.timeout ?? 10_000,
19+
);
1520
stream.on("data", (data) => {
1621
const line: string = data.toString();
1722
const matches = line.match(pattern);
1823
if (matches) {
19-
resolve(matches[0]);
24+
resolve(matches);
25+
clearTimeout(timeout);
2026
}
2127
});
2228
});

0 commit comments

Comments
 (0)