@yarnpkg/fslib
Advanced tools
Comparing version 3.0.0 to 3.0.1
@@ -8,2 +8,9 @@ "use strict"; | ||
const path_1 = require("./path"); | ||
function direntToPortable(dirent) { | ||
// We don't need to return a copy, we can just reuse the object the real fs returned | ||
const portableDirent = dirent; | ||
if (typeof dirent.path === `string`) | ||
portableDirent.path = path_1.npath.toPortablePath(dirent.path); | ||
return portableDirent; | ||
} | ||
class NodeFS extends FakeFS_1.BasePortableFakeFS { | ||
@@ -371,6 +378,16 @@ constructor(realFs = fs_1.default) { | ||
if (opts) { | ||
this.realFs.readdir(path_1.npath.fromPortablePath(p), opts, this.makeCallback(resolve, reject)); | ||
if (opts.recursive && process.platform === `win32`) { | ||
if (opts.withFileTypes) { | ||
this.realFs.readdir(path_1.npath.fromPortablePath(p), opts, this.makeCallback(results => resolve(results.map(direntToPortable)), reject)); | ||
} | ||
else { | ||
this.realFs.readdir(path_1.npath.fromPortablePath(p), opts, this.makeCallback(results => resolve(results.map(path_1.npath.toPortablePath)), reject)); | ||
} | ||
} | ||
else { | ||
this.realFs.readdir(path_1.npath.fromPortablePath(p), opts, this.makeCallback(resolve, reject)); | ||
} | ||
} | ||
else { | ||
this.realFs.readdir(path_1.npath.fromPortablePath(p), this.makeCallback(value => resolve(value), reject)); | ||
this.realFs.readdir(path_1.npath.fromPortablePath(p), this.makeCallback(resolve, reject)); | ||
} | ||
@@ -381,3 +398,13 @@ }); | ||
if (opts) { | ||
return this.realFs.readdirSync(path_1.npath.fromPortablePath(p), opts); | ||
if (opts.recursive && process.platform === `win32`) { | ||
if (opts.withFileTypes) { | ||
return this.realFs.readdirSync(path_1.npath.fromPortablePath(p), opts).map(direntToPortable); | ||
} | ||
else { | ||
return this.realFs.readdirSync(path_1.npath.fromPortablePath(p), opts).map(path_1.npath.toPortablePath); | ||
} | ||
} | ||
else { | ||
return this.realFs.readdirSync(path_1.npath.fromPortablePath(p), opts); | ||
} | ||
} | ||
@@ -384,0 +411,0 @@ else { |
{ | ||
"name": "@yarnpkg/fslib", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"license": "BSD-2-Clause", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
230428
5969