-
Notifications
You must be signed in to change notification settings - Fork 2
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
Save config to standard directories #3
Conversation
Seems like the build fails because |
This is a good PR, thank you! Let's not discuss coding style for the moment, could you remove the semicolons, so our linter is happy? Thanks! :) |
Alright, sorry I couldn't keep myself from bringing it up. 😃 |
@janl should be good now, right? |
cc @christophwitzko @finnp @boennemann as I’m on vacation 🌴 |
Thanks for letting me know, 🌞 enjoy your vacation @janl! |
Hey @Siilwyn, thanks for this improvement. I'm wondering whether we could encapsulate this code into it's own module. I'd like to avoid having this in here, and then it's also in Atom, and probably elsewhere. What do you think about creating a separate module that we could depend on in here? Best, |
Hi @boennemann, that sounds like a great idea. I just did more research on existing modules and think it would be a good idea to create a module that returns the OS-specific paths for cache, config and app data. So without actually writing or reading, keeping the scope small enough but also big enough to be useful. What are your thoughts on this? Usage would look like this in the existing code: var osStorePaths = require('os-store-paths')
// or var osConfigDir = require('os-store-paths').config()
var config
var getConfigDir = function () {
// If configuration exists in the old default path use it
try {
fs.accessSync(path.join(home(), '.greenkeeperrc'))
return home()
} catch (err) {
// Use OS-specific configuration directory
return osStorePaths.config()
// or return osConfigDir;
}
}
var configPath = path.join(getConfigDir(), '.greenkeeperrc')
try {
config = JSON.parse(fs.readFileSync(configPath))
} catch (e) {
config = {}
} |
Hey, this is a great PR A module for this sounds great, but better would be using an existing one. I found https://github.com/sindresorhus/conf, which is based on https://github.com/sindresorhus/env-paths which could be useful here. |
Thanks @finnp :) Didn't know such a module already existed, just pushed a chance to use this module instead. I've kept the original commit because I think it adds to the progression but I can squash them too if you prefer. |
Any update on this? I'm excited to see this getting merged. :) |
The config is read to and written from standard config directories using the "env-paths" module, rather than just stuffing it into the home directory. Old config files will automatically be migrated to the new location. BREAKING CHANGE: Config is no longer stored in `~/.greenkeeperrc` Closes #3, Closes #5
I just updated the main CLI with this new version: greenkeeperio/greenkeeper#282 I added a new command, so that |
Awesome! Thank you @boennemann :) |
Instead of placing the configuration file in the home directory it should be placed in the appropriate directory per OS. This doesn't introduce any breaking changes since it falls back to using the configuration in the home directory.
Atom has the same issue open, I got most of the paths and how to to implement this gracefully from there.