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

Use a class for help command and do some fixes to tests #2810

Closed
wants to merge 13 commits into from

Conversation

voxsim
Copy link
Contributor

@voxsim voxsim commented Feb 28, 2017

This is my first tiny step towards a Base Command class to clash the number of ifs in src/cli/index.js. The way is quite long :D

Summary
For now I fixed some tests and write the help command as es6 class.

Test plan
I fixed some tests before touching some code; please see the commits.
Added tests for cache command.

@bestander I hope you like what I do and I have some questions for you:

  1. Do you think is useful add an acceptance/feature test per command? It maybe be overkill but the code is too much entagled and if you agree we can remove in a second moment after the story ends if they are useless.
  2. I think I will open an issue and maybe I will do a checklist because it is quite long and maybe it is useful some feedbacks/help, what do you think?

Right I am working to have all classes with three static functions (run, hasWrapper, setFlags), and when I will be ready everything will be switched to instance function. I will open more pull request to be careful ;)

src/util/misc.js Outdated
@@ -62,3 +62,13 @@ export function camelCase(str: string): ?string {
return _camelCase(str);
}
}

export function findIndex(args: Array<string>, predicate: string): number {
Copy link
Member

Choose a reason for hiding this comment

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

Why don't you use args.findIndex()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ops you are right ^^' I really don't remember why did this

@bestander
Copy link
Member

@voxsim, thanks for bringing this up.
Let's open an issue to track gradual improvement.
This may require a few PRs, we need to split it into atomic steps.

@voxsim voxsim force-pushed the extract-base-command-class branch 2 times, most recently from b866205 to 9fd6224 Compare March 6, 2017 13:22
@bestander
Copy link
Member

Ping me when it is ready for review

@voxsim voxsim force-pushed the extract-base-command-class branch from 9fd6224 to 9ba40d2 Compare March 7, 2017 08:45
@voxsim
Copy link
Contributor Author

voxsim commented Mar 7, 2017

@bestander I think the code is ready for review; the failure of travis does not seem related to my last changes O.o

@voxsim
Copy link
Contributor Author

voxsim commented Mar 7, 2017

I added other commits because I had time and maybe you can give me some feedbacks on how I arrange the cache command class (before it was using buildSubCommand, maybe it is worse than before for you).


test.concurrent('should run bin command', async () => {
const stdout = await execCommand('bin', [], '', false);
expect(stdout[0]).toEqual(`${fixturesLoc}/node_modules/.bin`);
Copy link
Member

Choose a reason for hiding this comment

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

this test fails on windows CI (appveyor)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh what a newbie error ^^' i'll fix asap!

@voxsim voxsim force-pushed the extract-base-command-class branch from c76f977 to f867ed0 Compare March 7, 2017 15:39
@voxsim voxsim force-pushed the extract-base-command-class branch from f867ed0 to d6f3e20 Compare March 8, 2017 16:28
@voxsim voxsim force-pushed the extract-base-command-class branch from d6f3e20 to 2ae055a Compare March 8, 2017 16:41
@voxsim
Copy link
Contributor Author

voxsim commented Mar 8, 2017

@bestander AppVeyor breaks for both builds for:

Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL

That does not seem related to my changes (I haven't changed anything related to the installation command). Could you please check? I'll investigate further in the next days.

I added some tests for the cache command, now every change is tested properly!

@voxsim
Copy link
Contributor Author

voxsim commented Mar 11, 2017

Maybe this pull request #2887 is better. I will close this after discussing which is better.

@bestander bestander requested a review from arcanis April 7, 2017 18:36
@bestander
Copy link
Member

I'll assign @arcanis as reviewer of this and the alternative PR.
Good work, @voxsim, sorry for the delays, we are just trying to balance between fixing bugs, adding new features and improving code maintainability.
Sometimes the latter gets a lower priority.

@bestander
Copy link
Member

Overall I like the BaseCommand/SubCommand idea but I let @arcanis drive this with you

@voxsim
Copy link
Contributor Author

voxsim commented Apr 7, 2017

after some parallel work i want to address this in another way ;) tomorrow or sunday I will write something here or write another pull request.

Btw do you need some help about addressing issues or bugs? I can help, sorry for the last month but I was busy for personal reasons, but I should come back :p

@bestander
Copy link
Member

bestander commented Apr 7, 2017 via email

@voxsim
Copy link
Contributor Author

voxsim commented Apr 7, 2017

ok ;)

@voxsim
Copy link
Contributor Author

voxsim commented Apr 11, 2017

Right now I am closing this pull request in favor of #3105. Maybe in the future we will extract a base class, we will see :)

@voxsim voxsim closed this Apr 11, 2017
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.

2 participants