mirror of
https://github.com/denoland/deno.git
synced 2024-12-21 23:04:45 -05:00
chdir should require --allow-write (#4889)
This commit is contained in:
parent
1378df3364
commit
f8d83361cd
2 changed files with 6 additions and 5 deletions
5
cli/js/lib.deno.ns.d.ts
vendored
5
cli/js/lib.deno.ns.d.ts
vendored
|
@ -405,9 +405,6 @@ declare namespace Deno {
|
|||
export function cwd(): string;
|
||||
|
||||
/**
|
||||
* **UNSTABLE**: Currently under evaluation to decide if explicit permission is
|
||||
* required to change the current working directory.
|
||||
*
|
||||
* Change the current working directory to the specified path.
|
||||
*
|
||||
* Deno.chdir("/home/userA");
|
||||
|
@ -417,6 +414,8 @@ declare namespace Deno {
|
|||
* Throws `Deno.errors.NotFound` if directory not found.
|
||||
* Throws `Deno.errors.PermissionDenied` if the user does not have access
|
||||
* rights
|
||||
*
|
||||
* Requires --allow-write.
|
||||
*/
|
||||
export function chdir(directory: string): void;
|
||||
|
||||
|
|
|
@ -245,12 +245,14 @@ struct ChdirArgs {
|
|||
}
|
||||
|
||||
fn op_chdir(
|
||||
_state: &State,
|
||||
state: &State,
|
||||
args: Value,
|
||||
_zero_copy: Option<ZeroCopyBuf>,
|
||||
) -> Result<JsonOp, OpError> {
|
||||
let args: ChdirArgs = serde_json::from_value(args)?;
|
||||
set_current_dir(&args.directory)?;
|
||||
let d = PathBuf::from(&args.directory);
|
||||
state.check_write(&d)?;
|
||||
set_current_dir(&d)?;
|
||||
Ok(JsonOp::Sync(json!({})))
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue