Skip to content

Commit 9fe1019

Browse files
authored
remove folderExist func and use sync fs instead
1 parent 3c9af63 commit 9fe1019

1 file changed

Lines changed: 2 additions & 18 deletions

File tree

app/public/js/common/configLocation.js

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,6 @@ const fs = require('fs-extra');
22
const userHome = require('user-home');
33
const mkdirp = require('mkdirp');
44

5-
/**
6-
* Check if a given folder exists before trying to access any of it's children
7-
*
8-
* @param {String} folder The folder we're checking
9-
*/
10-
const folderExists = folder => {
11-
let exists = false;
12-
fs.statSync(folder, (err, stats) => {
13-
if (stats.isDirectory()) {
14-
exists = true;
15-
}
16-
});
17-
18-
return exists;
19-
};
20-
215
class Configuration {
226

237
/**
@@ -44,7 +28,7 @@ class Configuration {
4428
userConfigPath = `${userHome}/Library/Preferences/Soundnode`;
4529
}
4630

47-
if (!folderExists(userConfigPath)) {
31+
if (!fs.statSync(userConfigPath).isDirectory()) {
4832
mkdirp(userConfigPath, err => {
4933
if (err) {
5034
console.error(err);
@@ -84,4 +68,4 @@ class Configuration {
8468

8569
}
8670

87-
module.exports = Configuration;
71+
module.exports = Configuration;

0 commit comments

Comments
 (0)