File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,12 @@ module.exports.createClient = function(options) {
32
32
33
33
function FileSystemProvider ( options ) {
34
34
options = options || { } ;
35
+
36
+ if ( ! path . isAbsolute ( options . root ) ) {
37
+ var basePath = path . dirname ( path . dirname ( require . main . filename ) ) ;
38
+ options . root = path . join ( basePath , options . root ) ;
39
+ }
40
+
35
41
this . root = options . root ;
36
42
var exists = fs . existsSync ( this . root ) ;
37
43
if ( ! exists ) {
@@ -104,6 +110,11 @@ FileSystemProvider.prototype.getContainers = function(cb) {
104
110
fs . readdir ( self . root , function ( err , files ) {
105
111
var containers = [ ] ;
106
112
var tasks = [ ] ;
113
+
114
+ if ( ! files ) {
115
+ files = [ ] ;
116
+ }
117
+
107
118
files . forEach ( function ( f ) {
108
119
tasks . push ( fs . stat . bind ( fs , path . join ( self . root , f ) ) ) ;
109
120
} ) ;
Original file line number Diff line number Diff line change @@ -31,6 +31,21 @@ describe('FileSystem based storage provider', function() {
31
31
process . nextTick ( done ) ;
32
32
} ) ;
33
33
34
+ it ( 'should work even it is ran from other path' , function ( done ) {
35
+ process . chdir ( '../../../' ) ;
36
+
37
+ try {
38
+ console . log ( `running from ${ process . cwd ( ) } ` ) ;
39
+ client = new FileSystemProvider ( {
40
+ root : path . join ( __dirname , 'storage' ) ,
41
+ } ) ;
42
+
43
+ process . nextTick ( done ) ;
44
+ } catch ( error ) {
45
+ process . nextTick ( done ( error ) ) ;
46
+ }
47
+ } ) ;
48
+
34
49
it ( 'should complain if the root directory doesn\'t exist' , function ( done ) {
35
50
try {
36
51
client = new FileSystemProvider ( {
You can’t perform that action at this time.
0 commit comments