Skip to content

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

Description

@xuld
  • 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.

Activity

  1. changed the title [-]fs.copyFileSync(directory, target) no dot throw error on macOS[/-] [+]fs.copyFileSync(directory, directory) do not throw error on macOS[/+] on Jun 18, 2019
  2. changed the title [-]fs.copyFileSync(directory, directory) do not throw error on macOS[/-] [+]fs.copyFileSync(directory, directory) does not throw error on macOS[/+] on Jun 18, 2019
  3. added
    fsIssues and PRs related to file-system APIs and the fs module.
    libuvIssues and PRs related to the libuv dependency or the uv binding.
    macosIssues and PRs related to the macOS platform.
    on Jun 18, 2019
  4. ZYSzys commented on Jun 18, 2019

    @ZYSzys
    Member

    @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

  5. xuld commented on Jun 19, 2019

    @xuld
    Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    fsIssues and PRs related to file-system APIs and the fs module.libuvIssues and PRs related to the libuv dependency or the uv binding.macosIssues and PRs related to the macOS platform.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions