@@ -106,7 +106,7 @@ class MemoryFileSystem {
106
106
}
107
107
}
108
108
109
- readFileSync ( _path , encoding ) {
109
+ readFileSync ( _path , optionsOrEncoding ) {
110
110
const path = pathToArray ( _path ) ;
111
111
let current = this . data ;
112
112
let i = 0
@@ -122,6 +122,7 @@ class MemoryFileSystem {
122
122
throw new MemoryFileSystemError ( errors . code . ENOENT , _path ) ;
123
123
}
124
124
current = current [ path [ i ] ] ;
125
+ const encoding = typeof optionsOrEncoding === "object" ? optionsOrEncoding . encoding : optionsOrEncoding ;
125
126
return encoding ? current . toString ( encoding ) : current ;
126
127
}
127
128
@@ -206,8 +207,8 @@ class MemoryFileSystem {
206
207
throw new MemoryFileSystemError ( errors . code . ENOSYS , _path ) ;
207
208
}
208
209
209
- writeFileSync ( _path , content , encoding ) {
210
- if ( ! content && ! encoding ) throw new Error ( "No content" ) ;
210
+ writeFileSync ( _path , content , optionsOrEncoding ) {
211
+ if ( ! content && ! optionsOrEncoding ) throw new Error ( "No content" ) ;
211
212
const path = pathToArray ( _path ) ;
212
213
if ( path . length === 0 ) {
213
214
throw new MemoryFileSystemError ( errors . code . EISDIR , _path ) ;
@@ -221,7 +222,8 @@ class MemoryFileSystem {
221
222
}
222
223
if ( isDir ( current [ path [ i ] ] ) )
223
224
throw new MemoryFileSystemError ( errors . code . EISDIR , _path ) ;
224
- current [ path [ i ] ] = encoding || typeof content === "string" ? new Buffer ( content , encoding ) : content ;
225
+ const encoding = typeof optionsOrEncoding === "object" ? optionsOrEncoding . encoding : optionsOrEncoding ;
226
+ current [ path [ i ] ] = optionsOrEncoding || typeof content === "string" ? new Buffer ( content , encoding ) : content ;
225
227
return ;
226
228
}
227
229
0 commit comments