Skip to content
This repository was archived by the owner on Dec 12, 2021. It is now read-only.

Commit c0029d5

Browse files
author
Max Schmidt
committed
FIX: mkdir error
Fixes issue #5
1 parent fe6e0da commit c0029d5

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

lib/storage.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default class Storage {
1212
constructor(state) {
1313
if(state !== undefined && state !== null && typeof state === 'object') {
1414
if(state.dir !== undefined && state.dir !== null && typeof state.dir === 'string') {
15-
this.init(state.dir.split('/').join('\\'));
15+
this.init(state.dir);
1616
}
1717
}
1818
}
@@ -28,12 +28,19 @@ export default class Storage {
2828
destroy() {}
2929

3030
init(directory) {
31-
this.dir = directory;
32-
try {
33-
fs.statSync(this.storageDir+this.dir);
34-
} catch(e) {
35-
fs.mkdirSync(this.storageDir+this.dir);
36-
}
31+
var temp = '\\';
32+
var store = this.storageDir;
33+
directory.split('/').join('\\').split('\\').forEach(function(currentValue,index) {
34+
if(currentValue !== "" && currentValue !== " " && currentValue !== null && currentValue !== undefined) {
35+
temp += currentValue+'\\';
36+
try {
37+
fs.statSync(store+temp);
38+
} catch(e) {
39+
fs.mkdirSync(store+temp);
40+
}
41+
}
42+
});
43+
this.dir = temp;
3744
}
3845

3946
store(snippet) {

0 commit comments

Comments
 (0)