From fe7e3a12ca02792215f7598302c42113bcdc4458 Mon Sep 17 00:00:00 2001 From: Asher Gomez Date: Thu, 24 Nov 2022 14:00:31 +1100 Subject: 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. --- cli/main.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'cli/main.rs') 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; } -- cgit v1.2.3