summaryrefslogtreecommitdiff
path: root/cli/tests/testdata
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-02-22 22:45:35 -0500
committerGitHub <noreply@github.com>2023-02-22 22:45:35 -0500
commitb15f9e60a040e2e450e7ca9971a5fc07dbf8b94c (patch)
tree4290744b0c0a8f8f5d063322a650fdabf2d3150c /cli/tests/testdata
parentcc8e4a00aaf4c4fe959944c7400f2e259f7faae8 (diff)
feat(task): support scripts in package.json (#17887)
This is a super basic initial implementation. We don't create a `node_modules/.bin` folder at the moment and add it to the PATH like we should which is necessary to make command name resolution in the subprocess work properly (ex. you run a script that launches another script that then tries to launch an "npx command"... this won't work atm). Closes #17492
Diffstat (limited to 'cli/tests/testdata')
-rw-r--r--cli/tests/testdata/npm/registry/@denotest/bin/0.5.0/cli.mjs5
-rw-r--r--cli/tests/testdata/npm/registry/@denotest/bin/0.5.0/package.json5
-rw-r--r--cli/tests/testdata/task/both/deno.json6
-rw-r--r--cli/tests/testdata/task/both/deno_selected.out4
-rw-r--r--cli/tests/testdata/task/both/echo.out0
-rw-r--r--cli/tests/testdata/task/both/no_args.out7
-rw-r--r--cli/tests/testdata/task/both/package.json9
-rw-r--r--cli/tests/testdata/task/both/package_json_selected.out7
-rw-r--r--cli/tests/testdata/task/both/prefers_deno.out4
-rw-r--r--cli/tests/testdata/task/deno_json/deno.json (renamed from cli/tests/testdata/task/deno.json)0
-rw-r--r--cli/tests/testdata/task/deno_json/task_additional_args.out (renamed from cli/tests/testdata/task/task_additional_args.out)0
-rw-r--r--cli/tests/testdata/task/deno_json/task_additional_args_nested_strings.out (renamed from cli/tests/testdata/task/task_additional_args_nested_strings.out)0
-rw-r--r--cli/tests/testdata/task/deno_json/task_additional_args_no_logic.out (renamed from cli/tests/testdata/task/task_additional_args_no_logic.out)0
-rw-r--r--cli/tests/testdata/task/deno_json/task_additional_args_no_shell_expansion.out (renamed from cli/tests/testdata/task/task_additional_args_no_shell_expansion.out)0
-rw-r--r--cli/tests/testdata/task/deno_json/task_boolean_logic.out (renamed from cli/tests/testdata/task/task_boolean_logic.out)0
-rw-r--r--cli/tests/testdata/task/deno_json/task_cwd.out (renamed from cli/tests/testdata/task/task_cwd.out)0
-rw-r--r--cli/tests/testdata/task/deno_json/task_deno_exe_no_env.out (renamed from cli/tests/testdata/task/task_deno_exe_no_env.out)0
-rw-r--r--cli/tests/testdata/task/deno_json/task_exit_code_5.out (renamed from cli/tests/testdata/task/task_exit_code_5.out)0
-rw-r--r--cli/tests/testdata/task/deno_json/task_init_cwd.out (renamed from cli/tests/testdata/task/task_init_cwd.out)0
-rw-r--r--cli/tests/testdata/task/deno_json/task_init_cwd_already_set.out (renamed from cli/tests/testdata/task/task_init_cwd_already_set.out)0
-rw-r--r--cli/tests/testdata/task/deno_json/task_no_args.out (renamed from cli/tests/testdata/task/task_no_args.out)20
-rw-r--r--cli/tests/testdata/task/deno_json/task_non_existent.out (renamed from cli/tests/testdata/task/task_non_existent.out)20
-rw-r--r--cli/tests/testdata/task/deno_json/task_piped_stdin.out (renamed from cli/tests/testdata/task/task_piped_stdin.out)0
-rw-r--r--cli/tests/testdata/task/npx/non_existent.out2
-rw-r--r--cli/tests/testdata/task/npx/on_own.out2
-rw-r--r--cli/tests/testdata/task/npx/package.json6
-rw-r--r--cli/tests/testdata/task/package_json/bin.out10
-rw-r--r--cli/tests/testdata/task/package_json/echo.out1
-rw-r--r--cli/tests/testdata/task/package_json/no_args.out5
-rw-r--r--cli/tests/testdata/task/package_json/package.json10
30 files changed, 103 insertions, 20 deletions
diff --git a/cli/tests/testdata/npm/registry/@denotest/bin/0.5.0/cli.mjs b/cli/tests/testdata/npm/registry/@denotest/bin/0.5.0/cli.mjs
new file mode 100644
index 000000000..0ae8e9190
--- /dev/null
+++ b/cli/tests/testdata/npm/registry/@denotest/bin/0.5.0/cli.mjs
@@ -0,0 +1,5 @@
+import process from "node:process";
+
+for (const arg of process.argv.slice(2)) {
+ console.log(arg);
+}
diff --git a/cli/tests/testdata/npm/registry/@denotest/bin/0.5.0/package.json b/cli/tests/testdata/npm/registry/@denotest/bin/0.5.0/package.json
new file mode 100644
index 000000000..caa2ef538
--- /dev/null
+++ b/cli/tests/testdata/npm/registry/@denotest/bin/0.5.0/package.json
@@ -0,0 +1,5 @@
+{
+ "name": "@deno/bin",
+ "version": "0.5.0",
+ "bin": "./cli.mjs"
+}
diff --git a/cli/tests/testdata/task/both/deno.json b/cli/tests/testdata/task/both/deno.json
new file mode 100644
index 000000000..1038609a4
--- /dev/null
+++ b/cli/tests/testdata/task/both/deno.json
@@ -0,0 +1,6 @@
+{
+ "tasks": {
+ "output": "deno eval 'console.log(1)'",
+ "other": "deno eval 'console.log(2)'"
+ }
+}
diff --git a/cli/tests/testdata/task/both/deno_selected.out b/cli/tests/testdata/task/both/deno_selected.out
new file mode 100644
index 000000000..f55a74f5b
--- /dev/null
+++ b/cli/tests/testdata/task/both/deno_selected.out
@@ -0,0 +1,4 @@
+Download http://localhost:4545/npm/registry/@denotest/bin
+Download http://localhost:4545/npm/registry/@denotest/bin/1.0.0.tgz
+Task other deno eval 'console.log(2)'
+2
diff --git a/cli/tests/testdata/task/both/echo.out b/cli/tests/testdata/task/both/echo.out
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/cli/tests/testdata/task/both/echo.out
diff --git a/cli/tests/testdata/task/both/no_args.out b/cli/tests/testdata/task/both/no_args.out
new file mode 100644
index 000000000..fce690b70
--- /dev/null
+++ b/cli/tests/testdata/task/both/no_args.out
@@ -0,0 +1,7 @@
+Available tasks:
+- output
+ deno eval 'console.log(1)'
+- other
+ deno eval 'console.log(2)'
+- bin (package.json)
+ cli-esm testing this out
diff --git a/cli/tests/testdata/task/both/package.json b/cli/tests/testdata/task/both/package.json
new file mode 100644
index 000000000..708ccc6b1
--- /dev/null
+++ b/cli/tests/testdata/task/both/package.json
@@ -0,0 +1,9 @@
+{
+ "scripts": {
+ "bin": "cli-esm testing this out",
+ "output": "echo should never be called or shown"
+ },
+ "dependencies": {
+ "other": "npm:@denotest/bin@1.0"
+ }
+}
diff --git a/cli/tests/testdata/task/both/package_json_selected.out b/cli/tests/testdata/task/both/package_json_selected.out
new file mode 100644
index 000000000..76b3a9227
--- /dev/null
+++ b/cli/tests/testdata/task/both/package_json_selected.out
@@ -0,0 +1,7 @@
+Download http://localhost:4545/npm/registry/@denotest/bin
+Download http://localhost:4545/npm/registry/@denotest/bin/1.0.0.tgz
+Task bin cli-esm testing this out "asdf"
+testing
+this
+out
+asdf
diff --git a/cli/tests/testdata/task/both/prefers_deno.out b/cli/tests/testdata/task/both/prefers_deno.out
new file mode 100644
index 000000000..cd6798e6d
--- /dev/null
+++ b/cli/tests/testdata/task/both/prefers_deno.out
@@ -0,0 +1,4 @@
+Download http://localhost:4545/npm/registry/@denotest/bin
+Download http://localhost:4545/npm/registry/@denotest/bin/1.0.0.tgz
+Task output deno eval 'console.log(1)' "some" "text"
+1
diff --git a/cli/tests/testdata/task/deno.json b/cli/tests/testdata/task/deno_json/deno.json
index c57426d25..c57426d25 100644
--- a/cli/tests/testdata/task/deno.json
+++ b/cli/tests/testdata/task/deno_json/deno.json
diff --git a/cli/tests/testdata/task/task_additional_args.out b/cli/tests/testdata/task/deno_json/task_additional_args.out
index 8d04f961a..8d04f961a 100644
--- a/cli/tests/testdata/task/task_additional_args.out
+++ b/cli/tests/testdata/task/deno_json/task_additional_args.out
diff --git a/cli/tests/testdata/task/task_additional_args_nested_strings.out b/cli/tests/testdata/task/deno_json/task_additional_args_nested_strings.out
index 0e5f35c7f..0e5f35c7f 100644
--- a/cli/tests/testdata/task/task_additional_args_nested_strings.out
+++ b/cli/tests/testdata/task/deno_json/task_additional_args_nested_strings.out
diff --git a/cli/tests/testdata/task/task_additional_args_no_logic.out b/cli/tests/testdata/task/deno_json/task_additional_args_no_logic.out
index a4886a60d..a4886a60d 100644
--- a/cli/tests/testdata/task/task_additional_args_no_logic.out
+++ b/cli/tests/testdata/task/deno_json/task_additional_args_no_logic.out
diff --git a/cli/tests/testdata/task/task_additional_args_no_shell_expansion.out b/cli/tests/testdata/task/deno_json/task_additional_args_no_shell_expansion.out
index 826a3aaf1..826a3aaf1 100644
--- a/cli/tests/testdata/task/task_additional_args_no_shell_expansion.out
+++ b/cli/tests/testdata/task/deno_json/task_additional_args_no_shell_expansion.out
diff --git a/cli/tests/testdata/task/task_boolean_logic.out b/cli/tests/testdata/task/deno_json/task_boolean_logic.out
index 94ebaf900..94ebaf900 100644
--- a/cli/tests/testdata/task/task_boolean_logic.out
+++ b/cli/tests/testdata/task/deno_json/task_boolean_logic.out
diff --git a/cli/tests/testdata/task/task_cwd.out b/cli/tests/testdata/task/deno_json/task_cwd.out
index bfe3e7b11..bfe3e7b11 100644
--- a/cli/tests/testdata/task/task_cwd.out
+++ b/cli/tests/testdata/task/deno_json/task_cwd.out
diff --git a/cli/tests/testdata/task/task_deno_exe_no_env.out b/cli/tests/testdata/task/deno_json/task_deno_exe_no_env.out
index cf4a51b68..cf4a51b68 100644
--- a/cli/tests/testdata/task/task_deno_exe_no_env.out
+++ b/cli/tests/testdata/task/deno_json/task_deno_exe_no_env.out
diff --git a/cli/tests/testdata/task/task_exit_code_5.out b/cli/tests/testdata/task/deno_json/task_exit_code_5.out
index 12d171939..12d171939 100644
--- a/cli/tests/testdata/task/task_exit_code_5.out
+++ b/cli/tests/testdata/task/deno_json/task_exit_code_5.out
diff --git a/cli/tests/testdata/task/task_init_cwd.out b/cli/tests/testdata/task/deno_json/task_init_cwd.out
index 95ea8a545..95ea8a545 100644
--- a/cli/tests/testdata/task/task_init_cwd.out
+++ b/cli/tests/testdata/task/deno_json/task_init_cwd.out
diff --git a/cli/tests/testdata/task/task_init_cwd_already_set.out b/cli/tests/testdata/task/deno_json/task_init_cwd_already_set.out
index e427984d4..e427984d4 100644
--- a/cli/tests/testdata/task/task_init_cwd_already_set.out
+++ b/cli/tests/testdata/task/deno_json/task_init_cwd_already_set.out
diff --git a/cli/tests/testdata/task/task_no_args.out b/cli/tests/testdata/task/deno_json/task_no_args.out
index e41b3edd5..18f86fce6 100644
--- a/cli/tests/testdata/task/task_no_args.out
+++ b/cli/tests/testdata/task/deno_json/task_no_args.out
@@ -1,19 +1,19 @@
Available tasks:
- boolean_logic
sleep 0.1 && echo 3 && echo 4 & echo 1 && echo 2 || echo NOPE
-- deno_echo
- deno eval 'console.log(5)'
- echo
echo 1
+- deno_echo
+ deno eval 'console.log(5)'
+- strings
+ deno run main.ts && deno eval "console.log(\"test\")"
+- piped
+ echo 12345 | (deno eval 'const b = new Uint8Array(1);Deno.stdin.readSync(b);console.log(b)' && deno eval 'const b = new Uint8Array(1);Deno.stdin.readSync(b);console.log(b)')
+- exit_code_5
+ echo $(echo 10 ; exit 2) && exit 5
- echo_cwd
echo $(pwd)
-- echo_emoji
- echo 🔥
- echo_init_cwd
echo $INIT_CWD
-- exit_code_5
- echo $(echo 10 ; exit 2) && exit 5
-- piped
- echo 12345 | (deno eval 'const b = new Uint8Array(1);Deno.stdin.readSync(b);console.log(b)' && deno eval 'const b = new Uint8Array(1);Deno.stdin.readSync(b);console.log(b)')
-- strings
- deno run main.ts && deno eval "console.log(\"test\")"
+- echo_emoji
+ echo 🔥
diff --git a/cli/tests/testdata/task/task_non_existent.out b/cli/tests/testdata/task/deno_json/task_non_existent.out
index 0e70f24d9..efe3805f6 100644
--- a/cli/tests/testdata/task/task_non_existent.out
+++ b/cli/tests/testdata/task/deno_json/task_non_existent.out
@@ -2,19 +2,19 @@ Task not found: non_existent
Available tasks:
- boolean_logic
sleep 0.1 && echo 3 && echo 4 & echo 1 && echo 2 || echo NOPE
-- deno_echo
- deno eval 'console.log(5)'
- echo
echo 1
+- deno_echo
+ deno eval 'console.log(5)'
+- strings
+ deno run main.ts && deno eval "console.log(\"test\")"
+- piped
+ echo 12345 | (deno eval 'const b = new Uint8Array(1);Deno.stdin.readSync(b);console.log(b)' && deno eval 'const b = new Uint8Array(1);Deno.stdin.readSync(b);console.log(b)')
+- exit_code_5
+ echo $(echo 10 ; exit 2) && exit 5
- echo_cwd
echo $(pwd)
-- echo_emoji
- echo 🔥
- echo_init_cwd
echo $INIT_CWD
-- exit_code_5
- echo $(echo 10 ; exit 2) && exit 5
-- piped
- echo 12345 | (deno eval 'const b = new Uint8Array(1);Deno.stdin.readSync(b);console.log(b)' && deno eval 'const b = new Uint8Array(1);Deno.stdin.readSync(b);console.log(b)')
-- strings
- deno run main.ts && deno eval "console.log(\"test\")"
+- echo_emoji
+ echo 🔥
diff --git a/cli/tests/testdata/task/task_piped_stdin.out b/cli/tests/testdata/task/deno_json/task_piped_stdin.out
index f0a236c86..f0a236c86 100644
--- a/cli/tests/testdata/task/task_piped_stdin.out
+++ b/cli/tests/testdata/task/deno_json/task_piped_stdin.out
diff --git a/cli/tests/testdata/task/npx/non_existent.out b/cli/tests/testdata/task/npx/non_existent.out
new file mode 100644
index 000000000..5df04917e
--- /dev/null
+++ b/cli/tests/testdata/task/npx/non_existent.out
@@ -0,0 +1,2 @@
+Task non-existent npx this-command-should-not-exist-for-you
+npx: could not resolve command 'this-command-should-not-exist-for-you'
diff --git a/cli/tests/testdata/task/npx/on_own.out b/cli/tests/testdata/task/npx/on_own.out
new file mode 100644
index 000000000..67491f7b0
--- /dev/null
+++ b/cli/tests/testdata/task/npx/on_own.out
@@ -0,0 +1,2 @@
+Task on-own npx
+npx: missing command
diff --git a/cli/tests/testdata/task/npx/package.json b/cli/tests/testdata/task/npx/package.json
new file mode 100644
index 000000000..59602b96f
--- /dev/null
+++ b/cli/tests/testdata/task/npx/package.json
@@ -0,0 +1,6 @@
+{
+ "scripts": {
+ "non-existent": "npx this-command-should-not-exist-for-you",
+ "on-own": "npx"
+ }
+}
diff --git a/cli/tests/testdata/task/package_json/bin.out b/cli/tests/testdata/task/package_json/bin.out
new file mode 100644
index 000000000..ed1b6b8a2
--- /dev/null
+++ b/cli/tests/testdata/task/package_json/bin.out
@@ -0,0 +1,10 @@
+Download http://localhost:4545/npm/registry/@denotest/bin
+Download http://localhost:4545/npm/registry/@denotest/bin/0.5.0.tgz
+Download http://localhost:4545/npm/registry/@denotest/bin/1.0.0.tgz
+Task bin @denotest/bin hi && cli-esm testing this out && npx cli-cjs test "extra"
+hi
+testing
+this
+out
+test
+extra
diff --git a/cli/tests/testdata/task/package_json/echo.out b/cli/tests/testdata/task/package_json/echo.out
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/cli/tests/testdata/task/package_json/echo.out
@@ -0,0 +1 @@
+1
diff --git a/cli/tests/testdata/task/package_json/no_args.out b/cli/tests/testdata/task/package_json/no_args.out
new file mode 100644
index 000000000..de149ccf9
--- /dev/null
+++ b/cli/tests/testdata/task/package_json/no_args.out
@@ -0,0 +1,5 @@
+Available tasks:
+- echo (package.json)
+ deno eval 'console.log(1)'
+- bin (package.json)
+ @denotest/bin hi && cli-esm testing this out && npx cli-cjs test
diff --git a/cli/tests/testdata/task/package_json/package.json b/cli/tests/testdata/task/package_json/package.json
new file mode 100644
index 000000000..cedbe2d5b
--- /dev/null
+++ b/cli/tests/testdata/task/package_json/package.json
@@ -0,0 +1,10 @@
+{
+ "scripts": {
+ "echo": "deno eval 'console.log(1)'",
+ "bin": "@denotest/bin hi && cli-esm testing this out && npx cli-cjs test"
+ },
+ "dependencies": {
+ "@denotest/bin": "0.5",
+ "other": "npm:@denotest/bin@1.0"
+ }
+}