Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions scripts/foreach-example.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { execSync } from 'child_process';
import { execFileSync } from 'child_process';
import * as fs from 'fs';
import * as path from 'path';
import * as semver from 'semver';
Expand All @@ -11,7 +11,7 @@ function nodeReq(dir: string): string | undefined {
).engines?.node;
}

const cmd = process.argv.slice(2).join(' ');
const [cmd, ...cmdArgs] = process.argv.slice(2);
const root = path.join(__dirname, '..');
const examples = path.join(root, 'examples');

Expand All @@ -22,8 +22,10 @@ const dirs = fs
.filter((dir) => semver.satisfies(process.version, nodeReq(dir) || '>=16'));

for (const dir of dirs) {
console.log(`\x1b[97m> \x1b[37m${cmd} \x1b[90m<== \x1b[36m${dir}\x1b[0m`);
execSync(cmd, {
console.log(
`\x1b[97m> \x1b[37m${[cmd, ...cmdArgs].join(' ')} \x1b[90m<== \x1b[36m${dir}\x1b[0m`,
);
execFileSync(cmd, cmdArgs, {
stdio: 'inherit',
cwd: path.join(root, dir),
});
Expand Down
Loading