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

Commit d10bfda

Browse files
author
Max Schmidt
committed
FIX: Storage
1 parent 3c48b4d commit d10bfda

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

lib/storage.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { dirname } from 'path';
44
import Snippet from './snippet.js';
55
const fs = require('fs');
6+
const os = require('os');
67

78
export default class Storage {
89

@@ -12,7 +13,7 @@ export default class Storage {
1213
constructor(state) {
1314
if(state !== undefined && state !== null && typeof state === 'object') {
1415
if(state.dir !== undefined && state.dir !== null && typeof state.dir === 'string') {
15-
this.init(state.dir.split('/').join('\\'));
16+
this.init(state.dir);
1617
}
1718
}
1819
}
@@ -28,11 +29,22 @@ export default class Storage {
2829
destroy() {}
2930

3031
init(directory) {
31-
var temp = '\\';
3232
var store = this.storageDir;
33-
directory.split('/').join('\\').split('\\').forEach(function(currentValue,index) {
33+
var divider;
34+
35+
if(store.indexOf('/')>-1) {
36+
divider = '/';
37+
directory = directory.split('\\').join('/');
38+
} else if(store.indexOf('\\'>-1)) {
39+
divider = '\\';
40+
directory = directory.split('/').join('\\');
41+
}
42+
43+
var temp = divider;
44+
45+
directory.split(divider).forEach(function(currentValue,index) {
3446
if(currentValue !== "" && currentValue !== " " && currentValue !== null && currentValue !== undefined) {
35-
temp += currentValue+'\\';
47+
temp += currentValue+divider;
3648
try {
3749
fs.statSync(store+temp);
3850
} catch(e) {

0 commit comments

Comments
 (0)