From b15f9e60a040e2e450e7ca9971a5fc07dbf8b94c Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 22 Feb 2023 22:45:35 -0500 Subject: 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 --- cli/tests/testdata/task/both/deno.json | 6 ++++++ cli/tests/testdata/task/both/deno_selected.out | 4 ++++ cli/tests/testdata/task/both/echo.out | 0 cli/tests/testdata/task/both/no_args.out | 7 +++++++ cli/tests/testdata/task/both/package.json | 9 +++++++++ cli/tests/testdata/task/both/package_json_selected.out | 7 +++++++ cli/tests/testdata/task/both/prefers_deno.out | 4 ++++ 7 files changed, 37 insertions(+) create mode 100644 cli/tests/testdata/task/both/deno.json create mode 100644 cli/tests/testdata/task/both/deno_selected.out create mode 100644 cli/tests/testdata/task/both/echo.out create mode 100644 cli/tests/testdata/task/both/no_args.out create mode 100644 cli/tests/testdata/task/both/package.json create mode 100644 cli/tests/testdata/task/both/package_json_selected.out create mode 100644 cli/tests/testdata/task/both/prefers_deno.out (limited to 'cli/tests/testdata/task/both') 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 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 -- cgit v1.2.3