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

feat($cli): Add support for --no-scripts #150

Merged
merged 1 commit into from
Jul 12, 2017
Merged

Conversation

erikfox
Copy link
Contributor

@erikfox erikfox commented Jul 12, 2017

#143

What: Running a script will by default output the command text of the script to stdout, passing
--no-scripts will hide the command text.

Why: Some script commands are long and clutter console output when logged.

How: Added { scripts: ... } to options. Defaults true, pass --no-scripts sets to false.

scripts: ['test'],
options,
}).then(() => {
// expect(stdout).toEqual(...)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kentcdodds Could you advise on how you would capture stdout to test this? Currently no precedent in tests (that I've seen).

Choose a reason for hiding this comment

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

With looking at the code, I think we could use the infoSpy from setup().

const {runPackageScript, infoSpy} = setup()
// and in the test
expect(infoSpy.calledWith(...)) // or something familiar

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @tdeschryver will try this tonight.

@kentcdodds
Copy link
Collaborator

This is great! Thanks for working on it! I'll try to get to it as soon as I can (at a conference right now).

scripts: ['test'],
options,
}).then(() => {
expect(infoSpy.firstCall.args[0]).toMatch(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tdeschryver @kentcdodds Let me know if this is acceptable for a test case.

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.

Looking awesome!

Added some notes. Also, could you add some docs to the README?

scripts: ['test'],
options,
}).then(() => {
expect(infoSpy.firstCall.args[0]).toMatch(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why don't we do toMatchSnapshot instead? Will be easier to update in the future.

options,
}).then(() => {
expect(infoSpy.firstCall.args[0]).toMatch(
'\u001b[90mnps is executing\u001b[39m `\u001b[1mtest\u001b[22m`',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's do toMatchSnapshot here as well.

@codecov
Copy link

codecov bot commented Jul 12, 2017

Codecov Report

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

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #150   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          11     11           
  Lines         345    346    +1     
=====================================
+ Hits          345    346    +1
Impacted Files Coverage Δ
src/bin-utils/parser.js 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 c9e6a1e...d9cd4f9. Read the comment docs.

…output

Running a script will by default output the command text of the script to stdout, passing
--no-scripts will hide the command text.

sezna#143
@erikfox
Copy link
Contributor Author

erikfox commented Jul 12, 2017

@kentcdodds Done!

  • Document in README.md
  • .toMatchSnapshot()

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.

Awesome. Thanks!

@kentcdodds kentcdodds merged commit 074996b into sezna:master Jul 12, 2017
@kentcdodds
Copy link
Collaborator

Thank you so much!

@RichDonnellan
Copy link

Awesome! Can't wait to use it.

Next time I'll try my hand at my own feature request. 👍

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.

4 participants