From 695f314a913da3aa691381341385cbc1ef71b503 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Sat, 20 Apr 2024 20:13:46 -0400 Subject: feat(task): support running npm binary commands in deno.json (#23478) npm binary commands like `vite` from a `node_modules/.bin` folder will now execute when defined in a deno.json Closes https://github.com/denoland/deno/issues/23477 --- tests/integration/task_tests.rs | 56 --------------------------- tests/specs/task/byonm/__test__.jsonc | 20 ++++++++++ tests/specs/task/byonm/deno.json | 7 ++++ tests/specs/task/byonm/deno_json_say.out | 9 +++++ tests/specs/task/byonm/deno_json_think.out | 9 +++++ tests/specs/task/byonm/package.json | 10 +++++ tests/specs/task/byonm/package_json_say.out | 9 +++++ tests/specs/task/byonm/package_json_think.out | 9 +++++ 8 files changed, 73 insertions(+), 56 deletions(-) create mode 100644 tests/specs/task/byonm/__test__.jsonc create mode 100644 tests/specs/task/byonm/deno.json create mode 100644 tests/specs/task/byonm/deno_json_say.out create mode 100644 tests/specs/task/byonm/deno_json_think.out create mode 100644 tests/specs/task/byonm/package.json create mode 100644 tests/specs/task/byonm/package_json_say.out create mode 100644 tests/specs/task/byonm/package_json_think.out (limited to 'tests') diff --git a/tests/integration/task_tests.rs b/tests/integration/task_tests.rs index b64e329a5..4012081f7 100644 --- a/tests/integration/task_tests.rs +++ b/tests/integration/task_tests.rs @@ -3,11 +3,9 @@ // Most of the tests for this are in deno_task_shell. // These tests are intended to only test integration. -use deno_core::serde_json::json; use test_util::env_vars_for_npm_tests; use test_util::itest; use test_util::TestContext; -use test_util::TestContextBuilder; itest!(task_no_args { args: "task -q --config task/deno_json/deno.json", @@ -302,57 +300,3 @@ itest!(task_deno_no_pre_post { exit_code: 0, envs: vec![("NO_COLOR".to_string(), "1".to_string())], }); - -#[test] -fn task_byonm() { - let context = TestContextBuilder::for_npm().use_temp_cwd().build(); - let temp_dir = context.temp_dir().path(); - temp_dir.join("package.json").write_json(&json!({ - "name": "example", - "scripts": { - "say": "cowsay 'do make say'", - "think": "cowthink think" - }, - "dependencies": { - "cowsay": "*" - } - })); - temp_dir.join("deno.json").write_json(&json!({ - "unstable": ["byonm"], - })); - context.run_npm("install"); - - context - .new_command() - .args_vec(["task", "say"]) - .run() - .assert_matches_text( - r#"Task say cowsay 'do make say' - _____________ -< do make say > - ------------- - \ ^__^ - \ (oo)\_______ - (__)\ )\/\ - ||----w | - || || -"#, - ); - - context - .new_command() - .args_vec(["task", "think"]) - .run() - .assert_matches_text( - r#"Task think cowthink think - _______ -( think ) - ------- - o ^__^ - o (oo)\_______ - (__)\ )\/\ - ||----w | - || || -"#, - ); -} diff --git a/tests/specs/task/byonm/__test__.jsonc b/tests/specs/task/byonm/__test__.jsonc new file mode 100644 index 000000000..670f6767d --- /dev/null +++ b/tests/specs/task/byonm/__test__.jsonc @@ -0,0 +1,20 @@ +{ + "tempDir": true, + "steps": [{ + "commandName": "npm", + "args": "install", + "output": "[WILDCARD]" + }, { + "args": "task say", + "output": "package_json_say.out" + }, { + "args": "task think", + "output": "package_json_think.out" + }, { + "args": "task deno-say", + "output": "deno_json_say.out" + }, { + "args": "task deno-think", + "output": "deno_json_think.out" + }] +} diff --git a/tests/specs/task/byonm/deno.json b/tests/specs/task/byonm/deno.json new file mode 100644 index 000000000..53f85d07e --- /dev/null +++ b/tests/specs/task/byonm/deno.json @@ -0,0 +1,7 @@ +{ + "tasks": { + "deno-say": "cowsay 'do make say'", + "deno-think": "cowthink think" + }, + "unstable": ["byonm"] +} diff --git a/tests/specs/task/byonm/deno_json_say.out b/tests/specs/task/byonm/deno_json_say.out new file mode 100644 index 000000000..92ec40c80 --- /dev/null +++ b/tests/specs/task/byonm/deno_json_say.out @@ -0,0 +1,9 @@ +Task deno-say cowsay 'do make say' + _____________ +< do make say > + ------------- + \ ^__^ + \ (oo)\_______ + (__)\ )\/\ + ||----w | + || || diff --git a/tests/specs/task/byonm/deno_json_think.out b/tests/specs/task/byonm/deno_json_think.out new file mode 100644 index 000000000..b98762961 --- /dev/null +++ b/tests/specs/task/byonm/deno_json_think.out @@ -0,0 +1,9 @@ +Task deno-think cowthink think + _______ +( think ) + ------- + o ^__^ + o (oo)\_______ + (__)\ )\/\ + ||----w | + || || diff --git a/tests/specs/task/byonm/package.json b/tests/specs/task/byonm/package.json new file mode 100644 index 000000000..a5944c24f --- /dev/null +++ b/tests/specs/task/byonm/package.json @@ -0,0 +1,10 @@ +{ + "name": "example", + "scripts": { + "say": "cowsay 'do make say'", + "think": "cowthink think" + }, + "dependencies": { + "cowsay": "*" + } +} diff --git a/tests/specs/task/byonm/package_json_say.out b/tests/specs/task/byonm/package_json_say.out new file mode 100644 index 000000000..be5ee2236 --- /dev/null +++ b/tests/specs/task/byonm/package_json_say.out @@ -0,0 +1,9 @@ +Task say cowsay 'do make say' + _____________ +< do make say > + ------------- + \ ^__^ + \ (oo)\_______ + (__)\ )\/\ + ||----w | + || || diff --git a/tests/specs/task/byonm/package_json_think.out b/tests/specs/task/byonm/package_json_think.out new file mode 100644 index 000000000..ce6526939 --- /dev/null +++ b/tests/specs/task/byonm/package_json_think.out @@ -0,0 +1,9 @@ +Task think cowthink think + _______ +( think ) + ------- + o ^__^ + o (oo)\_______ + (__)\ )\/\ + ||----w | + || || -- cgit v1.2.3