1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-24 08:09:08 -05:00

feat(runtime): stabilize Deno.symlink and Deno.symlinkSync (#9226)

This commit is contained in:
Casper Beyer 2021-02-26 08:13:48 +08:00 committed by GitHub
parent e516e4d1d5
commit 2ac7798a20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 40 additions and 47 deletions

View file

@ -56,8 +56,6 @@ const UNSTABLE_DENO_PROPS: &[&str] = &[
"signal",
"signals",
"startTls",
"symlink",
"symlinkSync",
"systemMemoryInfo",
"systemCpuInfo",
"umask",

View file

@ -2273,4 +2273,42 @@ declare namespace Deno {
/** The URL of the entrypoint module entered from the command-line. */
export const mainModule: string;
export type SymlinkOptions = {
type: "file" | "dir";
};
/**
* Creates `newpath` as a symbolic link to `oldpath`.
*
* The options.type parameter can be set to `file` or `dir`. This argument is only
* available on Windows and ignored on other platforms.
*
* ```ts
* Deno.symlinkSync("old/name", "new/name");
* ```
*
* Requires `allow-write` permission. */
export function symlinkSync(
oldpath: string,
newpath: string,
options?: SymlinkOptions,
): void;
/**
* Creates `newpath` as a symbolic link to `oldpath`.
*
* The options.type parameter can be set to `file` or `dir`. This argument is only
* available on Windows and ignored on other platforms.
*
* ```ts
* await Deno.symlink("old/name", "new/name");
* ```
*
* Requires `allow-write` permission. */
export function symlink(
oldpath: string,
newpath: string,
options?: SymlinkOptions,
): Promise<void>;
}

View file

@ -36,46 +36,6 @@ declare namespace Deno {
rows: number;
};
export type SymlinkOptions = {
type: "file" | "dir";
};
/** **UNSTABLE**: This API needs a security review.
*
* Creates `newpath` as a symbolic link to `oldpath`.
*
* The options.type parameter can be set to `file` or `dir`. This argument is only
* available on Windows and ignored on other platforms.
*
* ```ts
* Deno.symlinkSync("old/name", "new/name");
* ```
*
* Requires `allow-write` permission. */
export function symlinkSync(
oldpath: string,
newpath: string,
options?: SymlinkOptions,
): void;
/** **UNSTABLE**: This API needs a security review.
*
* Creates `newpath` as a symbolic link to `oldpath`.
*
* The options.type parameter can be set to `file` or `dir`. This argument is only
* available on Windows and ignored on other platforms.
*
* ```ts
* await Deno.symlink("old/name", "new/name");
* ```
*
* Requires `allow-write` permission. */
export function symlink(
oldpath: string,
newpath: string,
options?: SymlinkOptions,
): Promise<void>;
/** **Unstable** There are questions around which permission this needs. And
* maybe should be renamed (loadAverage?)
*

View file

@ -88,6 +88,8 @@
fsync: __bootstrap.fs.fsync,
fdatasyncSync: __bootstrap.fs.fdatasyncSync,
fdatasync: __bootstrap.fs.fdatasync,
symlink: __bootstrap.fs.symlink,
symlinkSync: __bootstrap.fs.symlinkSync,
link: __bootstrap.fs.link,
linkSync: __bootstrap.fs.linkSync,
permissions: __bootstrap.permissions.permissions,
@ -128,8 +130,6 @@
futimeSync: __bootstrap.fs.futimeSync,
utime: __bootstrap.fs.utime,
utimeSync: __bootstrap.fs.utimeSync,
symlink: __bootstrap.fs.symlink,
symlinkSync: __bootstrap.fs.symlinkSync,
HttpClient: __bootstrap.fetch.HttpClient,
createHttpClient: __bootstrap.fetch.createHttpClient,
};

View file

@ -1203,7 +1203,6 @@ fn op_symlink_sync(
args: Value,
_zero_copy: &mut [ZeroCopyBuf],
) -> Result<Value, AnyError> {
super::check_unstable(state, "Deno.symlink");
let args: SymlinkArgs = serde_json::from_value(args)?;
let oldpath = PathBuf::from(&args.oldpath);
let newpath = PathBuf::from(&args.newpath);
@ -1254,8 +1253,6 @@ async fn op_symlink_async(
args: Value,
_zero_copy: BufVec,
) -> Result<Value, AnyError> {
super::check_unstable2(&state, "Deno.symlink");
let args: SymlinkArgs = serde_json::from_value(args)?;
let oldpath = PathBuf::from(&args.oldpath);
let newpath = PathBuf::from(&args.newpath);