mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 02:48:24 +00:00
feat(cli): add warning for incorrectly ordered flags (#16734)
This code checks if permission flags are incorrectly defined after the module name (e.g. `deno run mod.ts --allow-read` instead of the correct `deno run --allow-read mod.ts`). If so, a simple warning is displayed.
This commit is contained in:
parent
beaa0d8867
commit
fe7e3a12ca
4 changed files with 70 additions and 0 deletions
11
cli/main.rs
11
cli/main.rs
|
@ -686,6 +686,17 @@ async fn run_command(
|
|||
return run_from_stdin(flags).await;
|
||||
}
|
||||
|
||||
if !flags.has_permission() && flags.has_permission_in_argv() {
|
||||
log::warn!(
|
||||
"{}",
|
||||
crate::colors::yellow(
|
||||
r#"Permission flags have likely been incorrectly set after the script argument.
|
||||
To grant permissions, set them before the script argument. For example:
|
||||
deno run --allow-read=. main.js"#
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if flags.watch.is_some() {
|
||||
return run_with_watch(flags, run_flags.script).await;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue