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/tests/integration/run_tests.rs | 11 +++++++++++ cli/tests/testdata/run/permission_args.out | 4 ++++ 2 files changed, 15 insertions(+) create mode 100644 cli/tests/testdata/run/permission_args.out (limited to 'cli/tests') diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs index 192fff620..866fd2793 100644 --- a/cli/tests/integration/run_tests.rs +++ b/cli/tests/integration/run_tests.rs @@ -3647,3 +3647,14 @@ itest!(flash_shutdown { args: "run --unstable --allow-net run/flash_shutdown/main.ts", exit_code: 0, }); + +itest!(permission_args { + args: "run run/001_hello.js --allow-net", + output: "run/permission_args.out", + envs: vec![("NO_COLOR".to_string(), "1".to_string())], +}); + +itest!(permission_args_quiet { + args: "run --quiet run/001_hello.js --allow-net", + output: "run/001_hello.js.out", +}); diff --git a/cli/tests/testdata/run/permission_args.out b/cli/tests/testdata/run/permission_args.out new file mode 100644 index 000000000..6a1e1787c --- /dev/null +++ b/cli/tests/testdata/run/permission_args.out @@ -0,0 +1,4 @@ +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 +Hello World -- cgit v1.2.3