Skip to content

node:fs - cpSync doesn't respect options #27494

@dsherret

Description

@dsherret

Reproduction:

import { cpSync } from "node:fs";

for (let i = 0; i < 2; i++) {
  cpSync("folder", "other", {
    force: true,
    recursive: true
  });
}
> mkdir other
> node main.mjs
> deno run -A main.mjs
error: Uncaught (in promise) AlreadyExists: Cannot create a file when that file already exists. (os error 183)
  cpSync("folder", "other", {
  ^
    at cpSync (ext:deno_node/_fs/_fs_cp.js:17:3)
    at file:///V:/scratch/main.mjs:4:3

Reason is the op doesn't even use the options:

export function cpSync(src, dest, options) {
validateCpOptions(options);
const srcPath = getValidatedPath(src, "src");
const destPath = getValidatedPath(dest, "dest");
op_node_cp_sync(srcPath, destPath);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working correctlynode compat

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions