Closed deployable closed 6 years ago
mock-fs readlink will throw an EINVAL error when the destination object is missing. Node (v8.9.4) will throw a ENOENT
readlink
EINVAL
ENOENT
fs-extra relies on this behaviour for file existence detection during a copy.
mkdir -p /tmp/mockfs cd /tmp/mockfs yarn add mock-fs fs-extra mkdir adir touch afile ln -s afile alink
→ node > let fs = require('fs') > fs.readlinkSync('nope') Error: ENOENT: no such file or directory, readlink 'nope' at Object.fs.readlinkSync (fs.js:967:18) > let mockfs = require('mock-fs') > mockfs({ ... 'alink': mockfs.symlink({ path: 'afile' }), ... 'afile':'', ... 'adir':{}, ... }) > fs.readlinkSync('nope') Error: EINVAL, invalid argument 'nope' at Binding.<anonymous> (/private/tmp/mockfs/node_modules/mock-fs/lib/binding.js:1039:13) at maybeCallback (/private/tmp/mockfs/node_modules/mock-fs/lib/binding.js:42:17) at Binding.readlink (/private/tmp/mockfs/node_modules/mock-fs/lib/binding.js:1036:10) at Object.fs.readlinkSync (fs.js:967:18)
mock-fs
readlink
will throw anEINVAL
error when the destination object is missing. Node (v8.9.4) will throw aENOENT
fs-extra relies on this behaviour for file existence detection during a copy.