-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Replace optimist with nconf and look for .httpserverrc settings file #131
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
Conversation
Cool idea! Let me review this weekend. |
bin/http-server
Outdated
.argv; | ||
fs = require('fs'), | ||
path = require('path'), | ||
nconf = require('nconf') |
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.
Some people use this as a library. We should really be doing:
var nconf = require('nconf');
var config = new nconf.Provider()
.argv({
d: { boolean: true, default: true },
i: { boolean: true, default: true },
cors: { boolean: true }
});
+1 if you can rebase of |
186d77e
to
c2fa36a
Compare
Rebased and addressed comments. In the process I undid a small change I made to how the boolean |
Will take a look at this over the weekend or next week. |
1333595
to
5049fdb
Compare
5049fdb
to
6fd985a
Compare
This comment has been minimized.
This comment has been minimized.
6fd985a
to
df41ce6
Compare
This is an oldie, but a goodie. I'd like to revisit this again soon, so we can get off the abandoned |
27a8b27
to
7169b7f
Compare
An oldie indeed. Rebased onto current master, in light of the renewed interest. |
@timothykang I worked on replacing optimist with minimist in #464, which I still believe is a step in the right direction, but I have to say I like this nconf approach better! Would you mind taking a look at the merge confict in bin/http-server? Could you also look into specifying the current version of nconf, and make sure it doesn't break anything? Thank you! |
7169b7f
to
d911553
Compare
@thornjad Done! |
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.
@timothykang I'm sorry to ask once again, but my v0.12 merge train has created some more merge conflicts, and has also added some non-nconf settings which need to be converted. Could you take a look?
This PR is next in my merge train queue so master
will stop being moving target, I promise!
Also, go ahead and add yourself to the contributor list in package.json
, this is definitely a great contribution! (you don't have to if you don't want to).
bin/http-server
Outdated
|
||
var ifaces = os.networkInterfaces(); | ||
var config = new nconf.Provider().argv({ cors: { boolean: true } }), |
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.
Can we use aliases here so that we can avoid the pattern of, for example, config.get('p') || config.get('port')
? Instead, it would be nice to have
.argv({
port: {
alias: 'p'
}, ...
And then just use config.get('port')
.
Note that I think we should use the long form config values as the keys and the short versions as aliases (#464 (comment))
bin/http-server
Outdated
|
||
var port = config.get('p') || config.get('port') || parseInt(process.env.PORT, 10), | ||
host = config.get('a') || '0.0.0.0', | ||
ssl = !!config.get('S') || !!config.get('ssl'), |
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 think we can use parseValues: true
in .argv
above rather than need to coerce here. Correct me if I'm wrong on that, I haven't used nconf before.
3c0a893
to
bbc1fb8
Compare
@thornjad Rebased. I added value parsing for numbers and where it made sense, but I left the keys as the short forms since not every option had a long form (they could be easily added in a follow-on PR). |
bbc1fb8
to
d003290
Compare
d003290
to
3213aca
Compare
I guess this can probably be closed, now that #622 was merged instead (switch |
I thought JSHint's method of searching up the directory tree would work nicely, as it would allow projects to share settings while also allowing overrides.
Related to #67, closes #24.