mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 02:48:24 +00:00
fix(runtime/fs): preserve permissions in copyFileSync for macOS (#17412)
Fixes https://github.com/denoland/deno/issues/16921
This commit is contained in:
parent
68782346d0
commit
ae2981d7ac
2 changed files with 46 additions and 2 deletions
|
@ -209,3 +209,30 @@ Deno.test(
|
|||
}, Deno.errors.PermissionDenied);
|
||||
},
|
||||
);
|
||||
|
||||
function copyFileSyncMode(content: string): void {
|
||||
const tempDir = Deno.makeTempDirSync();
|
||||
const fromFilename = tempDir + "/from.txt";
|
||||
const toFilename = tempDir + "/to.txt";
|
||||
Deno.writeTextFileSync(fromFilename, content);
|
||||
Deno.chmodSync(fromFilename, 0o100755);
|
||||
|
||||
Deno.copyFileSync(fromFilename, toFilename);
|
||||
const toStat = Deno.statSync(toFilename);
|
||||
assertEquals(toStat.mode!, 0o100755);
|
||||
}
|
||||
|
||||
Deno.test(
|
||||
{
|
||||
ignore: Deno.build.os === "windows",
|
||||
permissions: { read: true, write: true },
|
||||
},
|
||||
function copyFileSyncChmod() {
|
||||
// this Tests different optimization paths on MacOS:
|
||||
//
|
||||
// < 128 KB clonefile() w/ fallback to copyfile()
|
||||
// > 128 KB
|
||||
copyFileSyncMode("Hello world!");
|
||||
copyFileSyncMode("Hello world!".repeat(128 * 1024));
|
||||
},
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue