This repository was archived by the owner on Dec 12, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed
Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change 33import { dirname } from 'path' ;
44import Snippet from './snippet.js' ;
55const fs = require ( 'fs' ) ;
6+ const os = require ( 'os' ) ;
67
78export 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 ) {
You can’t perform that action at this time.
0 commit comments