Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renaming file to filename with trailing '/' should fail with "ENOENT: no such file or directory". #227

Open
dienluong opened this issue Jan 13, 2018 · 0 comments

Comments

@dienluong
Copy link

dienluong commented Jan 13, 2018

On MacOS, with the real fs where file test-data/bob.txt exists, the following rename fails :

> fs.renameSync('test-data/bob.txt', 'test-data/pete/');
Error: ENOENT: no such file or directory, rename 'test-data/bob.txt' -> 'test-data/pete/'
    at Object.fs.renameSync (fs.js:766:18)
    at repl:1:4
    at ContextifyScript.Script.runInThisContext (vm.js:50:33)
    at REPLServer.defaultEval (repl.js:240:29)
    at bound (domain.js:301:14)
    at REPLServer.runBound [as eval] (domain.js:314:12)
    at REPLServer.onLine (repl.js:441:10)
    at emitOne (events.js:121:20)
    at REPLServer.emit (events.js:211:7)
    at REPLServer.Interface._onLine (readline.js:282:10)

But with mock-fs, it succeeds:

> let mockfs = require('mock-fs')
undefined
> mockfs({ 'test-data': { 'bob.txt': 'a text file' } })
undefined
> fs.renameSync('test-data/bob.txt', 'test-data/pete/');
undefined
> fs.readdirSync('test-data');
[ 'pete' ]

Thank you.

(On Windows, mock-fs is consistent with fs -- the rename would succeed with both.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant