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

fs.copyFileSync(directory, directory) does not throw error on macOS #28279

Closed
xuld opened this issue Jun 18, 2019 · 2 comments
Closed

fs.copyFileSync(directory, directory) does not throw error on macOS #28279

xuld opened this issue Jun 18, 2019 · 2 comments
Labels
fs Issues and PRs related to the fs subsystem / file system. libuv Issues and PRs related to the libuv dependency or the uv binding. macos Issues and PRs related to the macOS platform / OSX.

Comments

@xuld
Copy link

xuld commented Jun 18, 2019

  • Version:
    v10.12.0, v11.1.0
  • Platform:
    Darwin Mac.r 17.0.0 Darwin Kernel Version 17.0.0: Thu Aug 24 21:48:19 PDT 2017; root:xnu-4570.1.46~2/RELEASE_X86_64 x86_64
  • Subsystem:

Simply run the code below:

$ node
fs.mkdirSync('xyz')
fs.copyFileSync('xyz', 'abc')

On Windows, it results EPERM, but on mac, it creates an empty directory unexpectedly. The behaviours are not consistent.

Since the API is named copyFile, rather than copyDirectory, it should not be able to copy a directory, and should throw ENOTDIR in my first mind.

@xuld xuld changed the title fs.copyFileSync(directory, target) no dot throw error on macOS fs.copyFileSync(directory, directory) do not throw error on macOS Jun 18, 2019
@xuld xuld changed the title fs.copyFileSync(directory, directory) do not throw error on macOS fs.copyFileSync(directory, directory) does not throw error on macOS Jun 18, 2019
@ZYSzys ZYSzys added fs Issues and PRs related to the fs subsystem / file system. libuv Issues and PRs related to the libuv dependency or the uv binding. macos Issues and PRs related to the macOS platform / OSX. labels Jun 18, 2019
@ZYSzys
Copy link
Member

ZYSzys commented Jun 18, 2019

@xuld Yes, you are right. Could you try to upgrade your Node.js to v10.16.0(LTS) or our latest version?

I think it should be fixed (there would be error thrown) if using the latest Node.js.

Refs: #26936 #27241

@xuld
Copy link
Author

xuld commented Jun 19, 2019

I just tested v12.4.0, it has been fixed.

@xuld xuld closed this as completed Jun 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fs Issues and PRs related to the fs subsystem / file system. libuv Issues and PRs related to the libuv dependency or the uv binding. macos Issues and PRs related to the macOS platform / OSX.
Projects
None yet
Development

No branches or pull requests

2 participants