Skip to content

Commit dd54d92

Browse files
authored
fix: In FileSystem.js, special-case the cp command (#2264)
1 parent 8e331cc commit dd54d92

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/models/FileSystem.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ function isPromiseFs(fs) {
2020

2121
// List of commands all filesystems are expected to provide. `rm` is not
2222
// included since it may not exist and must be handled as a special case
23+
// Likewise with `cp`.
2324
const commands = [
24-
'cp',
2525
'readFile',
2626
'writeFile',
2727
'mkdir',
@@ -45,12 +45,14 @@ function bindFs(target, fs) {
4545
}
4646
}
4747

48-
// Handle the special case of `rm`
48+
// Handle the special cases of `rm` and `cp`
4949
if (isPromiseFs(fs)) {
50+
if (fs.cp) target._cp = fs.cp.bind(fs)
5051
if (fs.rm) target._rm = fs.rm.bind(fs)
5152
else if (fs.rmdir.length > 1) target._rm = fs.rmdir.bind(fs)
5253
else target._rm = rmRecursive.bind(null, target)
5354
} else {
55+
if (fs.cp) target._cp = pify(fs.cp.bind(fs))
5456
if (fs.rm) target._rm = pify(fs.rm.bind(fs))
5557
else if (fs.rmdir.length > 2) target._rm = pify(fs.rmdir.bind(fs))
5658
else target._rm = rmRecursive.bind(null, target)

0 commit comments

Comments
 (0)