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.

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