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

Utilize system specific config locations. #991

Merged
merged 10 commits into from
Jul 19, 2017

Conversation

jakejarrett
Copy link
Member

Linux configs utilize the XDG Specification ~/.config/soundnode/
Mac os utilizes what i could gather as ~/Library/Preferences/Soundnode

Not sure about the mac os location though.

Related Issue(s)

#989 (JavaScript Error when login without ROOT permissions)

Linux configs utilize the XDG Specification `~/.config/soundnode/`
Mac os utilizes what i could gather as `~/Library/Preferences/Soundnode`

Not sure about the mac os location though.
@@ -28,7 +29,19 @@ guiConfig.maximize = function () {
};

guiConfig.logOut = function () {
fs.removeSync(`${__dirname}/userConfig.json`);
let _userConfigPath = `${__dirname}/app/public/js/system/userConfig.json`; // Windows specific for now
Copy link
Member

Choose a reason for hiding this comment

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

in that case we should add a check if it's windows here too otherwise this will always be the case.

Copy link
Member

Choose a reason for hiding this comment

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

Let's name something else and not use _.

const userConfig = JSON.parse(fs.readFileSync(`${__dirname}/userConfig.json`, 'utf-8'));
const userHome = require('user-home');

let _userConfigPath = `${__dirname}/app/public/js/system/userConfig.json`; // Windows specific for now
Copy link
Member

@weblancaster weblancaster Jun 6, 2017

Choose a reason for hiding this comment

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

Let's export this to a function in util that returns the userConfigPath

@jakejarrett
Copy link
Member Author

I set it up as a class of its own that has no internal dependencies, Did you mean as a function inside the utilsService file, or does this suffice?

@weblancaster
Copy link
Member

weblancaster commented Jun 15, 2017

this is good @jakejarrett I will make some time to test.

Thanks.

let userConfigPath = null;

/** Linux platforms - XDG Standard */
if (process.platform === 'win32') {
Copy link
Member

@weblancaster weblancaster Jun 15, 2017

Choose a reason for hiding this comment

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

could this also be win64?

Copy link
Member Author

Choose a reason for hiding this comment

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

I do not believe so, This was written according to the nodejs documentation for process.platform which only lists win32 (I think it refers to the win32 api, not windows 32bit)

Copy link
Member

Choose a reason for hiding this comment

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

ok cool. thanks.

@weblancaster
Copy link
Member

@jakejarrett I tested here and it's failing to start the app. Right after clicking on the Facebook button to login.
screen shot 2017-06-16 at 4 15 13 pm

This adds a private function (Possibly could abstract it out to a class,
but it's not used anywhere else) to simply determine if a given location
is a folder & if it exists.
@jakejarrett
Copy link
Member Author

Pushed the fix for that 👍

@jakejarrett
Copy link
Member Author

@weblancaster Any update on this?

*/
const folderExists = folder => {
let exists = false;
fs.stat(folder, (err, stats) => { if (stats.isDirectory()) exists = true; });
Copy link
Member

Choose a reason for hiding this comment

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

can you format the code please @jakejarrett

Copy link
Member

Choose a reason for hiding this comment

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

Use fs.statSync to avoid race conditions since Node is async and we are returning exists before this is done.

}

if (!folderExists(userConfigPath)) {
mkdirp(userConfigPath, err => { if (err) console.error(err); });
Copy link
Member

Choose a reason for hiding this comment

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

please format the code to be multiple lines.

@jakejarrett
Copy link
Member Author

@weblancaster Updated code w/ those changes 👍

@weblancaster
Copy link
Member

weblancaster commented Jul 19, 2017

@jakejarrett I have pushed a couple of commits with changes based on my suggestion on sync fs but I also refactored to make a bit easier to work with the get functions removing the static get and replacing the class to object literal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants