Skip to content
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

Merged
merged 1 commit into from May 27, 2017

Conversation

Miklet
Copy link
Collaborator

@Miklet Miklet commented Apr 23, 2017

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.

@Miklet Miklet requested a review from kentcdodds April 23, 2017 19:05
@codecov-io
Copy link

codecov-io commented Apr 23, 2017

Codecov Report

Merging #136 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #136   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          10     10           
  Lines         302    308    +6     
=====================================
+ Hits          302    308    +6
Impacted Files Coverage Δ
src/bin-utils/initialize/index.js 100% <100%> (ø) ⬆️
src/get-script-to-run.js 100% <100%> (ø) ⬆️
src/index.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 061b5c3...274ebd3. Read the comment docs.

Copy link
Collaborator

@kentcdodds kentcdodds left a 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)?

@kentcdodds
Copy link
Collaborator

Thanks for working on this!

@Miklet
Copy link
Collaborator Author

Miklet commented Apr 24, 2017

It looks like that:
test

@kentcdodds
Copy link
Collaborator

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?

@Miklet
Copy link
Collaborator Author

Miklet commented Apr 24, 2017

Yes, it does make sense if I understood it properly 😄 So instead of:
nps is executing fo.b.ba: echo "foo.bar.baz"
you expect:
nps is executing foo.bar.baz: echo "foo.bar.baz". Am I right?

@kentcdodds
Copy link
Collaborator

Correct 😀

@Miklet
Copy link
Collaborator Author

Miklet commented Apr 24, 2017

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.

@Miklet
Copy link
Collaborator Author

Miklet commented Apr 25, 2017

Added script's name resolving. Let me know if you like it and I will squash commits into one before merge.

Copy link
Collaborator

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! More questions :)


export default resolveScriptName

function resolveScriptName(scriptToFind, scriptsConfig) {
Copy link
Collaborator

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)

Copy link
Collaborator Author

@Miklet Miklet Apr 25, 2017

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.

Copy link
Collaborator

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 😄

Copy link
Collaborator Author

@Miklet Miklet Apr 25, 2017

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.

Copy link
Collaborator

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?

Copy link
Collaborator

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 :)

Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator

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 👍

@Miklet Miklet force-pushed the pr/executing_text branch 2 times, most recently from a04d526 to 06558c4 Compare May 26, 2017 21:49
@Miklet
Copy link
Collaborator Author

Miklet commented May 26, 2017

Hi, I bumped up a version of prefix-matches and used the newest version to resolve the issue.

Copy link
Collaborator

@kentcdodds kentcdodds left a 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\"
Copy link
Collaborator

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', () =>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool 👍

scriptToRun = resolveScriptObjectToString(scriptToRun)
}
return {
resolvedPrefix,
Copy link
Collaborator

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.

Copy link
Collaborator Author

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
@Miklet
Copy link
Collaborator Author

Miklet commented May 27, 2017

Updated with your comments.

Copy link
Collaborator

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect!

@kentcdodds
Copy link
Collaborator

Thank you for this!

@kentcdodds kentcdodds merged commit 76bee57 into master May 27, 2017
@kentcdodds kentcdodds deleted the pr/executing_text branch May 27, 2017 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants