Skip to content

Commit

Permalink
paralellize external adder initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel3108 committed Oct 5, 2024
1 parent ab0566f commit 5dab2ef
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions packages/adder-testing-library/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ export async function prepareSnaphotTests(
}
}

function runAdder(
async function runAdder(
adder: AdderWithoutExplicitArgs,
cwd: string,
options: OptionValues<Record<string, Question>>
Expand All @@ -274,15 +274,25 @@ function runAdder(
changedFiles.forEach((file) => filesToFormat.add(file));
} else if (config.integrationType === 'external') {
try {
console.log('execute external adder');
execSync('npx ' + config.command, {
const program = spawn('npx', config.command.split(' '), {
stdio: 'pipe',
shell: true,
cwd,
env: Object.assign(process.env, config.environment ?? {}),
stdio: 'pipe'
env: Object.assign(process.env, config.environment ?? {})
});

await new Promise((resolve, reject) => {
program.on('exit', (code) => {
if (code == 0) {
resolve(undefined);
} else {
reject();
}
});
});
} catch (error) {
const typedError = error as Error;
throw new Error('Failed executing external command: ' + typedError.message);
throw new Error('Failed executing external command: ' + typedError);
}
} else {
throw new Error('Unknown integration type');
Expand Down

0 comments on commit 5dab2ef

Please sign in to comment.