Skip to content

Commit

Permalink
fix: support bun in addition to tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
exKAZUu committed May 15, 2024
1 parent d219fd1 commit 1fc92bd
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,18 @@ export const run: CommandModule<unknown, InferredOptionTypes<typeof builder>> =

const file = argv.file?.toString() || '';

const args = ['--no-warnings', '--import', 'tsx', file];
const isRunningOnBun = process.argv[0].endsWith('/bun');
const runtime = isRunningOnBun ? 'bun' : 'node';
const args = isRunningOnBun ? [] : ['--no-warnings', '--import', 'tsx', file];
if (argv.watch) {
args.push('--watch');
}
const [, ...additionalArguments] = argv._;
const runtimeArgs = [...args, ...additionalArguments.map((arg) => arg.toString())];
if (argv.verbose) {
console.info(`Running 'node ${[...args, ...additionalArguments.map((arg) => arg.toString())].join(' ')}'`);
console.info(`Running '${runtime} ${runtimeArgs.join(' ')}'`);
}
const ret = child_process.spawnSync('node', [...args, ...additionalArguments.map((arg) => arg.toString())], {
const ret = child_process.spawnSync(runtime, runtimeArgs, {
stdio: 'inherit',
env: { ...process.env, NODE_NO_WARNINGS: '1' },
});
Expand Down

0 comments on commit 1fc92bd

Please sign in to comment.