diff options
author | Asher Gomez <ashersaupingomez@gmail.com> | 2022-11-24 14:00:31 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-24 03:00:31 +0000 |
commit | fe7e3a12ca02792215f7598302c42113bcdc4458 (patch) | |
tree | 1bea37db723f77c96eec000ece5c738ab6f0eef8 /cli/main.rs | |
parent | beaa0d88679c96e643f411d04a4ce9f6d159eaeb (diff) |
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.
Diffstat (limited to 'cli/main.rs')
-rw-r--r-- | cli/main.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/cli/main.rs b/cli/main.rs index b91540c37..f18c3c976 100644 --- a/cli/main.rs +++ b/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; } |