mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 18:38:33 +00:00
feat: URL support in Deno filesystem methods (#5990)
This commit is contained in:
parent
813210d433
commit
818a801092
28 changed files with 741 additions and 66 deletions
|
@ -18,6 +18,25 @@ unitTest(
|
|||
}
|
||||
);
|
||||
|
||||
unitTest(
|
||||
{ ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
|
||||
function chmodSyncUrl(): void {
|
||||
const enc = new TextEncoder();
|
||||
const data = enc.encode("Hello");
|
||||
const tempDir = Deno.makeTempDirSync();
|
||||
const fileUrl = new URL(`file://${tempDir}/test.txt`);
|
||||
Deno.writeFileSync(fileUrl, data, { mode: 0o666 });
|
||||
|
||||
Deno.chmodSync(fileUrl, 0o777);
|
||||
|
||||
const fileInfo = Deno.statSync(fileUrl);
|
||||
assert(fileInfo.mode);
|
||||
assertEquals(fileInfo.mode & 0o777, 0o777);
|
||||
|
||||
Deno.removeSync(tempDir, { recursive: true });
|
||||
}
|
||||
);
|
||||
|
||||
// Check symlink when not on windows
|
||||
unitTest(
|
||||
{
|
||||
|
@ -89,6 +108,25 @@ unitTest(
|
|||
}
|
||||
);
|
||||
|
||||
unitTest(
|
||||
{ ignore: Deno.build.os === "windows", perms: { read: true, write: true } },
|
||||
async function chmodUrl(): Promise<void> {
|
||||
const enc = new TextEncoder();
|
||||
const data = enc.encode("Hello");
|
||||
const tempDir = Deno.makeTempDirSync();
|
||||
const fileUrl = new URL(`file://${tempDir}/test.txt`);
|
||||
Deno.writeFileSync(fileUrl, data, { mode: 0o666 });
|
||||
|
||||
await Deno.chmod(fileUrl, 0o777);
|
||||
|
||||
const fileInfo = Deno.statSync(fileUrl);
|
||||
assert(fileInfo.mode);
|
||||
assertEquals(fileInfo.mode & 0o777, 0o777);
|
||||
|
||||
Deno.removeSync(tempDir, { recursive: true });
|
||||
}
|
||||
);
|
||||
|
||||
// Check symlink when not on windows
|
||||
|
||||
unitTest(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue