Skip to content

Commit 550a491

Browse files
author
cod1k
committed
Refactor asyncExec to simplify spawn options handling
Revised the `asyncExec` function to use `Omit<SpawnOptions, 'shell'|'stdio'>`, ensuring better type safety and cleaner code. Standardized `spawn` options by including predefined `stdio` settings for consistent process output handling.
1 parent 020b352 commit 550a491

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';
@@ -13,17 +13,9 @@ const DEFAULT_DSN = 'https://username@domain/123';
1313
const DEFAULT_SENTRY_ORG_SLUG = 'sentry-javascript-sdks';
1414
const DEFAULT_SENTRY_PROJECT = 'sentry-javascript-e2e-tests';
1515

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

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

0 commit comments

Comments
 (0)