-
Notifications
You must be signed in to change notification settings - Fork 82
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
Fixes #90 by passing flags down as args for run commands #214
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me the change looks good. just one thing that the ws
run command is a little different from other but you have already pointed it out. and the exec
command already does that for ws
.
src/commands/project/run.js
Outdated
.slice(3) | ||
.filter( | ||
(arg, idx) => args.indexOf(arg) === -1 && !(arg === 'run' && idx === 0) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be inside a util
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, might just try removing the scriptArgs completely and removing the extra indexOf here.
At that point, its quite a simple function, still want it in a util?
src/commands/project/run.js
Outdated
return { | ||
cwd: options.string(flags.cwd, 'cwd'), | ||
script, | ||
scriptArgs | ||
scriptArgs: [...scriptArgs, ...flagArgs] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏
@jamiebuilds changed those scripts to just use argv now, much cleaner. Going to merge. Edit: Except it breaks the tests. Dammit. So, the tests break because of how they pass flags in. Looking at it now though.... I'm wondering if that was ever quite right.... (this is
The way we use
In the test we are passing in the flags as args, not flags. i.e running something like
would normally call
So, we're in an interesting place.... Getting this test to pass is gonna be tricky, I'd have to mock process.argv, which seems a little dangerous... Other than that, I'd kind of want to look at rewriting this flag passing logic to maybe just give us access to the raw flags but still be able to keep typing information for flags that are recognized... I can confirm that this change works though... ... Any thoughts @jamiebuilds ? |
Hey @jamiebuilds I've skipped the tests for now and I'm leaning towards just changing how we pass args. I'll leave this up for a couple more days in case you've got thoughts 👌 |
Thanks heaps for the patience everyone!
The solution I ended up going with is basically what was outlined here
With each of these ways to run a script
The way you would now pass flags is exactly as you'd expect
The only different one is the
ws run
commandThe things we are trading off here are
The implementation
This wasn't as clean as I'd hoped. You'll see the comments I added, but basically, because meow has already parsed all our flags, there's no perfect way to pass them down accurately without reaching out and using
process.argv
directly.This also makes writing tests for this a much bigger PITA. I'm willing to come back to those at some point after I do some investigations today.
Leaving this PR up now to get some feedback.
CC: @jamiebuilds @marcins @d4rkr00t @bradleyayers @drew-walker