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
refactor(cli): display which script is executed #136
Conversation
Codecov Report
@@ Coverage Diff @@
## master #136 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 10 10
Lines 302 308 +6
=====================================
+ Hits 302 308 +6
Continue to review full report at Codecov.
|
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.
Could we get a test to see what it looks like when I run a script foo.bar.baz
(for example), but use the prefix fo.b.ba
(for example)?
Thanks for working on this! |
Thanks for the screenshot! The use case is: I've entered a prefix version of the script, so I know what I entered. I want to see the full name of the script to validate that the script that's running is the one I'm thinking. Does that make sense? |
Yes, it does make sense if I understood it properly 😄 So instead of: |
Correct 😀 |
It seemed to be pretty easy issue but it turned out to be a little bit more complicated. I thought that there is somewhere some lonely variable with resolved script name but I was wrong 😄 I am thinking now about some function which will try to find matching key by a value by traversing recurisvely script's object. I will encapsulate it to separate module and it will be easy to test. |
Added script's name resolving. Let me know if you like it and I will squash commits into one before merge. |
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.
Thanks! More questions :)
src/resolve-script-name.js
Outdated
|
||
export default resolveScriptName | ||
|
||
function resolveScriptName(scriptToFind, scriptsConfig) { |
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.
Rather than scriptToFind
, could this be passed the prefix? (like fo.baz.f
could find foo.baz.foobar
)
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.
Not really, because this function search for a property by given value (scriptToFind
). Function which resolves what you mentioned is already implemented and it is a prefix-matcher
package.
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.
Sorry, what I meant to say was, that's what I'd rather it do 😄
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.
I understand, but I actually think the way it is, it is better. Because I don't see a way to get resolved script name by it's prefix in other way than reimplementing prefix-matcher
😄 I may be wrong, correct me if you see other solution.
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.
Couldn't we extend getScriptToRun
to get the script name in addition to the script command?
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.
Couldn't we extend getScriptToRun to get the script name in addition to the script command?
Maybe. Without looking at the code I'm unsure. If so, that'd be great.
reimplementing
prefix-matcher
Maybe we could contribute back and expose a method to do what we need :)
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.
Note that I have merge (and maybe release?) rights on that repo.
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.
The best solution in my opinion would to be contribute to prefix-matcher
, implement returning property (whole chain, not only the deepest) and then we could extend getScriptToRun
with it.
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.
That sounds good to me 👍
a04d526
to
06558c4
Compare
Hi, I bumped up a version of |
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 is looking great! I'm really excited to get this. Thanks for all your work on this!
@@ -12,7 +12,7 @@ lint.sub.hiddenThing | |||
exports[`test with --require 1`] = ` | |||
Object { | |||
"stderr": "", | |||
"stdout": "nps executing: echo \"log\" | |||
"stdout": "nps is executing log: echo \"log\" |
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.
Could this be:
nps is executing `log`: echo "log"
@@ -17,6 +17,9 @@ test('with --require', () => | |||
test('with --get-yargs-completions', () => | |||
snapshot('--config ./package-scripts.js --get-yargs-completions li')) | |||
|
|||
test('with prefix', () => |
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.
Cool 👍
src/get-script-to-run.js
Outdated
scriptToRun = resolveScriptObjectToString(scriptToRun) | ||
} | ||
return { | ||
resolvedPrefix, |
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.
Could we call this scriptName
instead? Because it's not the prefix, it's actually what the prefix was resolved to, which should be the full script name.
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.
Yea, that would actually be much better name.
Updated prefix-matches verion and added script name of executed script
Updated with your comments. |
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.
Perfect!
Thank you for this! |
Added an additional information displaying which script is executed.
What: Added information which script is executed.
Why: Because of #126
How: Just added an additional chalk call and changed string concatenation for template literal.