From 36ebc03f177cc7db5deb93f4d403cafbed756eb5 Mon Sep 17 00:00:00 2001 From: Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> Date: Tue, 24 Sep 2024 12:23:57 -0700 Subject: fix(cli): Warn on not-run lifecycle scripts with global cache (#25786) Refactors the lifecycle scripts code to extract out the common functionality and then uses that to provide a warning in the global resolver. While ideally we would still support them with the global cache, for now a warning is at least better than the status quo (where people are unaware why their packages aren't working). --- tests/specs/npm/lifecycle_scripts/__test__.jsonc | 29 ++++++++++++++++-------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'tests/specs/npm/lifecycle_scripts/__test__.jsonc') diff --git a/tests/specs/npm/lifecycle_scripts/__test__.jsonc b/tests/specs/npm/lifecycle_scripts/__test__.jsonc index f7a722a8b..201e42497 100644 --- a/tests/specs/npm/lifecycle_scripts/__test__.jsonc +++ b/tests/specs/npm/lifecycle_scripts/__test__.jsonc @@ -1,7 +1,7 @@ { + "tempDir": true, "tests": { "node_gyp": { - "tempDir": true, "steps": [ { "args": "cache --allow-scripts=npm:@denotest/node-addon main.js", @@ -14,7 +14,6 @@ ] }, "run_without_scripts": { - "tempDir": true, "steps": [ { "args": "run -A main.js", @@ -24,11 +23,9 @@ ] }, "implicit_node_gyp": { - "tempDir": true, "steps": [ { "envs": { - // I don't think this will work on windows "PATH": "" }, "args": "cache --allow-scripts implicit_node_gyp.js", @@ -38,7 +35,6 @@ ] }, "lifecycle_scripts": { - "tempDir": true, "steps": [ { // without running scripts (should warn) @@ -55,8 +51,25 @@ } ] }, + "global_lifecycle_scripts": { + "steps": [ + { + "args": ["eval", "Deno.removeSync('deno.json')"], + "output": "" + }, + { + // without running scripts (should warn) + "args": "install -e all_lifecycles.js", + "output": "all_lifecycles_not_run_global.out" + }, + { + // should not warn + "args": "install -e all_lifecycles.js", + "output": "" + } + ] + }, "only_warns_first": { - "tempDir": true, "steps": [ { // without running scripts (should warn) @@ -96,7 +109,6 @@ ] }, "lifecycle_scripts_conflicting_bin": { - "tempDir": true, "steps": [ { // we import @denotest/says-hello-on-install, which executes `say-hello` from `@denotest/say-hello` in its @@ -110,7 +122,6 @@ ] }, "fsevents_default_install_script": { - "tempDir": true, "steps": [ { "if": "mac", @@ -125,7 +136,6 @@ ] }, "lifecycle_scripts_no_deno_json": { - "tempDir": true, "steps": [ { "args": ["eval", "Deno.removeSync('deno.json')"], @@ -138,7 +148,6 @@ ] }, "lifecycle_scripts_no_deno_json_conflicting_bin": { - "tempDir": true, "steps": [ { "args": ["eval", "Deno.removeSync('deno.json')"], -- cgit v1.2.3