From d5d78839be0ed1c39bdee0c2b20627d94107f4ed Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Fri, 12 Jul 2019 08:19:22 +1200 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20refactor=20`#mkdir`=20to?= =?UTF-8?q?=20be=20compatible=20w/=20`strictNullChecks`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/volume.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/volume.ts b/src/volume.ts index 3ca91150..b624e625 100644 --- a/src/volume.ts +++ b/src/volume.ts @@ -337,7 +337,7 @@ const mkdirDefaults: IMkdirOptions = { mode: MODE.DIR, recursive: false, }; -const getMkdirOptions = options => { +const getMkdirOptions = (options): IMkdirOptions => { if (typeof options === 'number') return extend({}, mkdirDefaults, { mode: options }); return extend({}, mkdirDefaults, options); }; @@ -1848,8 +1848,9 @@ export class Volume { mkdir(path: TFilePath, callback: TCallback); mkdir(path: TFilePath, mode: TMode | IMkdirOptions, callback: TCallback); mkdir(path: TFilePath, a: TCallback | TMode | IMkdirOptions, b?: TCallback) { - const [options, callback] = getArgAndCb(a, b); - const opts = getMkdirOptions(options); + const opts: TMode | IMkdirOptions = getMkdirOptions(a); + const callback: TCallback = validateCallback(typeof a === 'function' ? a : b); + const modeNum = modeToNumber(opts.mode, 0o777); const filename = pathToFilename(path); if (opts.recursive) this.wrapAsync(this.mkdirpBase, [filename, modeNum], callback);