Skip to content

Commit 3a920f7

Browse files
committed
fix: only read --help & --version when no arguments
1 parent c96315f commit 3a920f7

1 file changed

Lines changed: 29 additions & 5 deletions

File tree

src/cli.ts

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { watchCommand } from './watch';
55

66
cli({
77
name: 'tsx',
8-
version,
98
parameters: ['[script path]'],
109
commands: [
1110
watchCommand,
@@ -15,12 +14,37 @@ cli({
1514
type: Boolean,
1615
description: 'Disable caching',
1716
},
17+
version: {
18+
type: Boolean,
19+
description: 'Show version',
20+
},
21+
help: {
22+
type: Boolean,
23+
alias: 'h',
24+
description: 'Show help',
25+
},
1826
},
19-
help: {
20-
description: 'Node.js runtime enhanced with esbuild for loading TypeScript & ESM',
21-
},
27+
help: false,
2228
}, (argv) => {
23-
run(argv._, {
29+
if (argv._.length === 0) {
30+
if (argv.flags.version) {
31+
console.log(version);
32+
return;
33+
}
34+
35+
if (argv.flags.help) {
36+
argv.showHelp({
37+
description: 'Node.js runtime enhanced with esbuild for loading TypeScript & ESM',
38+
});
39+
return;
40+
}
41+
}
42+
43+
const args = process.argv.slice(2).filter(
44+
argument => (argument !== '--no-cache' && argument !== '--noCache'),
45+
);
46+
47+
run(args, {
2448
noCache: Boolean(argv.flags.noCache),
2549
}).on(
2650
'close',

0 commit comments

Comments
 (0)