feat(runtime): support URL overloads for Deno.rename/Deno.renameSync (#10512)

This commit is contained in:
Casper Beyer 2021-06-03 22:14:37 +08:00 committed by GitHub
parent 844a1317ec
commit dc69b03339
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 55 additions and 5 deletions

View file

@ -1322,7 +1322,10 @@ declare namespace Deno {
* they are. It's always an error to rename anything to a non-empty directory.
*
* Requires `allow-read` and `allow-write` permissions. */
export function renameSync(oldpath: string, newpath: string): void;
export function renameSync(
oldpath: string | URL,
newpath: string | URL,
): void;
/** Renames (moves) `oldpath` to `newpath`. Paths may be files or directories.
* If `newpath` already exists and is not a directory, `rename()` replaces it.
@ -1339,7 +1342,10 @@ declare namespace Deno {
* they are. It's always an error to rename anything to a non-empty directory.
*
* Requires `allow-read` and `allow-write` permission. */
export function rename(oldpath: string, newpath: string): Promise<void>;
export function rename(
oldpath: string | URL,
newpath: string | URL,
): Promise<void>;
/** Synchronously reads and returns the entire contents of a file as utf8
* encoded string. Reading a directory throws an error.