-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Refactoring cli index #2613
Refactoring cli index #2613
Conversation
Ops there are some regressions and I forget to lint my code, sorry ^^' I'll let you know when I finished ;) |
36aec1c
to
23bb7fc
Compare
I finished with one test skipped, but @bestander do you know why we delete the args after References:
Maybe I can add another test after understanding the use case Let me know! |
23bb7fc
to
e8229f1
Compare
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.
@voxsim we ignore arguments after --
for run
command, for example.
You can do yarn run test -- no-cache
and no-cache
argument will be passed through as argument to whatever is executed in test
command.
Could you rebase on master to trigger tests?
src/cli/commands/help.js
Outdated
} | ||
} | ||
|
||
const getDocsLink = (name) => `https://yarnpkg.com/en/docs/cli/${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.
We moved the hardcoded paths to src/constants.js, could you put it there?
src/cli/commands/help.js
Outdated
for (let i = 0; i < args.length; i++) { | ||
const arg = args[i]; | ||
if (arg === '--') { | ||
args = args.slice(0, i); |
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.
should you have a break statement here?
@@ -160,7 +140,7 @@ if (command && typeof command.setFlags === 'function') { | |||
command.setFlags(commander); | |||
} | |||
|
|||
if (commandName === 'help' || args.indexOf('--help') >= 0 || args.indexOf('-h') >= 0) { | |||
if (args.indexOf('--help') >= 0 || args.indexOf('-h') >= 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.
why commandName is not used anymore?
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 if now covers only the 2nd case, before it was covering the the 1st, 2nd and the 3rd.
@voxsim, thanks for the PR, it looks good. |
e8229f1
to
671ab12
Compare
@bestander I added a Test Plan and rebased with master. IMHO we should create a Command class to clash the number of ifs and maybe delegate some stuff to it or its child (e.g. only the run command should do stuff with --). If you like the idea I can go ahead with other pull request after this one ;) |
@voxsim, thanks for the tests and a great test plan. |
It seems that this PR is failing the AppVeyor builds: https://ci.appveyor.com/project/kittens/yarn/build/1646/job/9hcyyn0tj9xh7ldk#L309 This test is also failing for other pull requests. |
Thanks, @TimvdLippe.
|
@bestander @TimvdLippe The main problem is the test itself: I do some tricks to test a npm script with arguments and for simplicity I used a bash script. First of all, we can skip the test if we are on windows and maybe think to do another test with the same trick in powershell, what do you think? |
Skipping for win32 should be fine imho
…On Tue, 21 Feb 2017 at 14:13, Simon Vocella ***@***.***> wrote:
@bestander <https://github.com/bestander> @TimvdLippe
<https://github.com/TimvdLippe> The main problem is the test itself: I do
some tricks to test a npm script with arguments and for simplicity I used a
bash script. First of all, we can skip the test if we are on windows and
maybe think to do another test with the same trick in powershell, what do
you think?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2613 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ACBdWGMkHi8JhqMB9BwMZzHXOtmYNgldks5revENgaJpZM4L0fXN>
.
|
I almost cover with tests every case in src/cli/index.js and after I extracted an help command.
This simplify the file and maybe it enables some other refactorings.
cheers :D
voxsim
EDIT:
Test Plan, I think I covered almost every case in the cli, in detail: