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
Create a speccy.yml Config File for common options #93
Conversation
This PR only seems to cover the I know there are a lot of options, but we talked about how each of them should be able to be set in the config file... and this PR doesn't do any of that. |
lint.js
Outdated
@@ -80,10 +85,14 @@ More information: https://speccy.io/rules/#${rule.name} | |||
|
|||
const command = async (file, cmd) => { | |||
const verbose = cmd.quiet ? 1 : cmd.verbose; | |||
let rules = [].concat(cmd.rules); |
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 need to concat a single array with itself. This is just making a copy as there is only one array there.
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.
fixed
lint.js
Outdated
|
||
linter.initialize(); | ||
|
||
await loader.loadRuleFiles(cmd.rules, { verbose }); | ||
if(fs.existsSync(process.env["NODE_CONFIG_DIR"] + "/default.yml")) { |
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 is what you were doing before, and we moved away from it. You dont need to check for the existance of a config file, just let rules = [].concat(cmd.rules, config.get('lint.rules'));
and if there is no config file there will be no rules!
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 overlooked the config.has()
method and incorrectly compensated for the resulting errors. That has been corrected.
test/linter.test.js
Outdated
const rules = config.get('lint.rules'); | ||
|
||
it('gets rules', () => { | ||
if(rules); |
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 test is not doing anything?
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.
fixed
ecf3ad1
to
cb5d188
Compare
@@ -40,6 +46,12 @@ const command = async (specFile, cmd) => { | |||
verbose | |||
}); | |||
|
|||
let port = cmd.port; |
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 cli interface should probably override given config file values, not the other way around.
This does make things a bit tricky trying to do it in the command files, because cmd.port
has a default value, set in speccy.js
This means that instead of just doing something simple like this:
const port = config.get('serve.port') || cmd.port;
... we'd need to use config.get()
in speccy.js and use it to define the default values.
That might look like this in speccy.js:
.option('-p, --port [value]', 'port on which the server will listen', config.get('serve.port') || 5000)
This means the CLI option is used if provided, then serve.port is inspected. If no value is set, it'll use 5000 as the default port!
Similar stuff will have to be done for the other options too.
eea265b
to
3ee560d
Compare
3ee560d
to
a3f7b5e
Compare
Closing in favour of #102. Thanks for the prototype and hard work on this! |
No description provided.