forked from blockapps/strato-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
41 lines (39 loc) · 868 Bytes
/
utils.js
File metadata and controls
41 lines (39 loc) · 868 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const fs = require("fs");
module.exports = {
/**
* Synchronously checks if provided file exists or not
* @param file {string}
* @returns {Promise}
*/
fsFileExistsSync: file => {
return new Promise((resolve, reject) => {
try {
resolve(fs.statSync(file).isFile());
} catch (err) {
if (err.code === "ENOENT") {
resolve(false);
} else {
reject(err);
}
}
});
},
/**
* Synchronously checks if provided folder exists or not
* @param dir {string}
* @returns {Promise}
*/
fsDirExistsSync: dir => {
return new Promise((resolve, reject) => {
try {
resolve(fs.statSync(dir).isDirectory());
} catch (err) {
if (err.code === "ENOENT") {
resolve(false);
} else {
reject(err);
}
}
});
}
};