-
Notifications
You must be signed in to change notification settings - Fork 8
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
Conversation
# Conflicts: # src/index.ts
const itemPath = path.join(__dirname, item); | ||
const itemStats = await stats(itemPath); | ||
|
||
return itemStats.isDirectory() ? import(`@/command/${item}/program`) : undefined; |
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.
Automatically register commands if they are a directory in the src/command
dir
src/command/index.ts
Outdated
await this.output(reports, commandOptions); | ||
} | ||
|
||
if (hasFailure) { |
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.
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).
options: [ | ||
{ | ||
description: 'Disable checking bundle sizes', | ||
flag: '--no-bundle-size', |
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.
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?
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.
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; |
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.
Would Object.assign(this, config) work to add these configs to this?
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.
No description provided.