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

Abstract out command creation to a class to reduce boilterplate as much as we can #25

Merged
merged 5 commits into from
Apr 17, 2019

Conversation

mitchellsimoens
Copy link
Collaborator

No description provided.

const itemPath = path.join(__dirname, item);
const itemStats = await stats(itemPath);

return itemStats.isDirectory() ? import(`@/command/${item}/program`) : undefined;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Automatically register commands if they are a directory in the src/command dir

await this.output(reports, commandOptions);
}

if (hasFailure) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here, if the command throws an error it will be determined to be a failure. I like this except if we want to generate reports or output to the cli what it returns. We may want to go down a normalized "REST" response where there is a success and data property and failure is then determined off that success (and an error prop to log out) and outputs can use the data. This can be done in a separate PR where we get pass/fail support for all commands (not just the size checkers).

@mitchellsimoens mitchellsimoens mentioned this pull request Apr 17, 2019
options: [
{
description: 'Disable checking bundle sizes',
flag: '--no-bundle-size',
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need a --no-directory-size option as well or directory checking will just be a part of bundle size checking soon so this is fine?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'd say since you are about to do some work in this area, I'd say we keep it to a single option (--no-size or whatever). I think if people want to get more advanced then that's where the config files will come into play as we can then allow them to be more fine grained with what they want to disable.

this.command = config.command;
this.options = config.options;
this.output = config.output;
this.title = config.title;
Copy link
Contributor

Choose a reason for hiding this comment

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

Would Object.assign(this, config) work to add these configs to this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You cannot in TypeScript, you'll get errors like this:

Screen_Shot_2019-04-17_at_10_52_33_AM

@mitchellsimoens mitchellsimoens merged commit 43ba89f into master Apr 17, 2019
@mitchellsimoens mitchellsimoens deleted the command_creator branch April 17, 2019 14:56
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

2 participants