-
-
Notifications
You must be signed in to change notification settings - Fork 622
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
fix(help): display error message if no option provided on startup #254
fix(help): display error message if no option provided on startup #254
Conversation
added demandCommand options for yargs by default requires one option to be speicified will throw an error otherwise
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.
It looks good. Could you add a test please? Also, build fails on one test
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.
Hi @sumit-gupta91 nice work! Can you add a test case? Here's a workflow:
https://github.com/webpack/webpack/blob/master/test/README.md
We use jest, so you can add a new folder with the same syntax as the others, just replace the matchers with what you'd expect
Thanks for the review, will go through the tests and add the test case ASAP. |
Great! Ping me if you need help :) |
test case to match the text when webpack-cli is run with no-options
Seems like the bintestcases aren't running, can you use yarn install to see if that fixes the issue? |
I tried what was mentioned in webpack documentation.
Yarn install works fine. |
@sumit-gupta91 right, could you rebase against master? This should be fixed in a newer version of the master branch |
Aaah right, so we have 0CJS, you should add this at the very end of the processing of options, so the compiler can do a trial run. When webpack is called we have a try catch clause, could you add this in the catch block? |
HI @sumit-gupta91 , everything okay here? 💙 |
Sorry guys for such a late response as I was on a leave for sometime, Wanted a break from work. I was not able to understand the last comment
|
So the reason why your test are failing is because webpack can compile without args, try adding the error message in the catch clause in bin/webpack |
I am not able to understand it, should I change the approach and rather than using demand I should use an if else in /bin/webpack.js or an enhancement has to be done. If it is the first option that has to be implemented I would like to understand the code flow. |
I think that you should let webpack try to parse without args, and if it output's any errors regarding no path specified, you can throw the help flag. If you look at the 0CJS PR, you can also see if there's anything missing from that in order to decide if we should output the help flag |
Okay will try this solution and update the PR |
exit webpack if defaults are not found fix test cases for no options
Hi @ev1stensberg have fixed the test cases and updated the code base. |
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.
Can you rebase to the next
branch, and remove the two dependencies that we use? It would be better to have it minimal for now 👍almost LGTM here after that's done, just gotta tripple-check and get some more eyes on this! CC @ematipico @EugeneHlushko
expect(stdout[5]).toContain("ERROR in Entry module not found"); | ||
expect(stdout[6]).toContain(""); | ||
expect(stdout[3]).toContain("Insufficient number of arguments provided"); | ||
expect(stdout[4]).toContain("Alternatively, run `webpack(-cli) --help` for usage info"); |
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.
im afraid people will literally run webpack(-cli) --help
:(
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.
Yeah that's true. I think the wording webpack
} | ||
} else { | ||
const statsString = stats.toString(outputOptions); | ||
if (statsString) stdout.write(statsString + "\n"); |
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 for being out of context here, but from reading the PR history i dont understand why we are printing out output options on a successful compilation?
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 else statement should be discarded. On a failed compilation it will throw if no options are set, or?
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.
oh yes, now i got the idea, thanks man! 👍
* chore(dependencies): fix vulnerabilities * misc(scripts): update clean:all script * chore(dependencies): fix vulnerabilities
@sumit-gupta91 Thanks for your update. I labeled the Pull Request so reviewers will review it again. @ematipico Please review the new changes. |
Hi @ev1stensberg, I have merged the next branch in my current branch. What are the two dependencies to be removed ?. One more thing I did a merge instead of rebase will it make a difference ? |
I am not able to a yarn install. Second I am getting this error ""global-modules-path" is not found. (node/no-missing-require)" can someone please help me out here |
Ouch, doing the merge caused some issue as far as I can see :( sometimes it's better to apply a rebase in order to not drag the commits from other branches. I think the better solution is to create a fresh new branch from next and doing a cherry-pick of your commits. Let's see git fetch upstream
git checkout https://github.com/sumit-gupta91/webpack-cli
git checkout next
git checkout -b bugfix/error-message
git cherry-pick 580395a281c6dda405d15025f72f4c4418ce7315
git cherry-pick 37cb6d81a3f2d144e427361c0e48f663464e1a12
git cherry-pick d43ab9f8a08935d60b7523f8efbec80db80cbb7a
git cherry-pick 5a040bae8e4172bbdc20d385c2defe869cada975
git push Note that those commits are yours. Those are the changes that you applied to your own branch, so you will have those commits also locally and you will be able to pick them without problems. Try this locally. And after that, while trying to create a PR, see if the only changes that you see are yours only. Please direct your PR to next |
Yes this was I was stuck from quite sometime because next and master have conflicts, will create a new branch from next and then just add the files which were changed. @ematipico one more question in this branch whenever i am trying to do |
I am still not able to figure it out, on checking out a branch form next. If I do yarn install I get an error, if I do npm install it works, but npm run test does not works. What am i doing wrong here ? |
We don't use yarn but we use npm for our developmenta. Give it a try and see if you get any errors. About the tests, what kind of errors you get? Do you run them inside and integrated console inside your IDE? If so, that might be the problem, it happens to me sometime. |
I used npm install, after that npm run test throws this error.
I am using normal terminal to run the test and not the terminal associated with VSCode |
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 you open a new PR that targets the next
branch?
@ev1stensberg I have opened a new branch .#466 |
added demandCommand options for yargs
by default requires one option to be speicified
will throw an error otherwise
What kind of change does this PR introduce?
bugfix
Did you add tests for your changes?
If relevant, did you update the documentation?
Summary
#124
Does this PR introduce a breaking change?
No
Other information