-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for execute typescript subcommand via ts-node #849
Conversation
Exactly what I was looking for, thanks @abetomo |
LGTM |
Should this be working in commander v2.20.0? Do I need to do anything to make it work? It works with .js files but I can't get it to work once I switch them to .ts. The top-level one works but my 'cmd-subcommand' shows nothing. |
Yes.
No.
Just have directure structure like this (see test fixture):
Thereafter you can execute script: node -r ts-node/register bin/pm.ts
Can you reproduce your issue? |
Thanks for the reply, @KillWolfVlad! I fixed my problem although I'm not really sure why. I'm doing a #! script and it wasn't working with |
These solutions didn't work for my use case, nothing was getting executed and no errors were thrown. But here's something that worked: Changing line 795 from proc = spawn(process.argv[0], args, { stdio: 'inherit' }); to proc = spawn(args.shift(), args, { stdio: 'inherit' }); However, I don't know if this would break something else, I just thought to post this here if others encounter the same problem. |
I've submitted a new PR: #1243 |
Command.prototype.executeSubCommand
doesn't support.ts
extension for scripts. It is bad if you want run something via ts-node.commander.js/index.js
Line 526 in e5b27cc
First, hardcoded
.js
extension is bad. I suggest use real file extension.commander.js/index.js
Lines 544 to 546 in e5b27cc
Second, I suggest use similar block of code for check exists file with
.ts
extension. I don't think that this duplication is serious.