Skip to content

Commit af78dda

Browse files
author
cod1k
committed
Refactor asyncExec to improve process output handling
Replace manual stdout/stderr piping with predefined stdio settings for concise and reliable output handling. Also, update the asyncExec function signature to use a stricter SpawnOptions type with omitted 'shell' and 'stdio' properties.
1 parent 5dc6dce commit af78dda

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

dev-packages/e2e-tests/run.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable no-console */
2-
import { spawn } from 'child_process';
2+
import { type SpawnOptions, spawn } from 'child_process';
33
import * as dotenv from 'dotenv';
44
import { mkdtemp, rm } from 'fs/promises';
55
import { sync as globSync } from 'glob';
@@ -12,17 +12,9 @@ const DEFAULT_DSN = 'https://username@domain/123';
1212
const DEFAULT_SENTRY_ORG_SLUG = 'sentry-javascript-sdks';
1313
const DEFAULT_SENTRY_PROJECT = 'sentry-javascript-e2e-tests';
1414

15-
function asyncExec(command: string, options: { env: Record<string, string | undefined>; cwd: string }): Promise<void> {
15+
function asyncExec(command: string, options: Omit<SpawnOptions, 'shell'|'stdio'>): Promise<void> {
1616
return new Promise((resolve, reject) => {
17-
const process = spawn(command, { ...options, shell: true });
18-
19-
process.stdout.on('data', data => {
20-
console.log(`${data}`);
21-
});
22-
23-
process.stderr.on('data', data => {
24-
console.error(`${data}`);
25-
});
17+
const process = spawn(command, { ...options, shell: true, stdio: ['ignore', 'inherit', 'inherit'] });
2618

2719
process.on('error', error => {
2820
reject(error);

0 commit comments

Comments
 (0)