summaryrefslogtreecommitdiff
path: root/tests/specs
diff options
context:
space:
mode:
authorNathan Whitaker <17734409+nathanwhit@users.noreply.github.com>2024-09-26 10:13:33 -0700
committerGitHub <noreply@github.com>2024-09-26 17:13:33 +0000
commit543c687c3474233d674ba9938c40c9a33fab61e8 (patch)
tree3aff7af00892a16ce0a0240011f45116df4ab49f /tests/specs
parent13c53d9727e0e529d04fd8b7709cb84b723fb0d8 (diff)
feat(install): warn repeatedly about not-run lifecycle scripts on explicit installs (#25878)
Currently we only warn once. With this PR, we continue to warn about not-run scripts on explicit `deno install` (or cache). For `run` (or other subcommands) we only warn the once, as we do currently.
Diffstat (limited to 'tests/specs')
-rw-r--r--tests/specs/npm/lifecycle_scripts/__test__.jsonc14
-rw-r--r--tests/specs/npm/lifecycle_scripts/all_lifecycles_global.js3
-rw-r--r--tests/specs/npm/lifecycle_scripts/all_lifecycles_not_run_global_cached.out7
-rw-r--r--tests/specs/npm/lifecycle_scripts/warns_again_on_install.out6
4 files changed, 28 insertions, 2 deletions
diff --git a/tests/specs/npm/lifecycle_scripts/__test__.jsonc b/tests/specs/npm/lifecycle_scripts/__test__.jsonc
index 201e42497..b798b968f 100644
--- a/tests/specs/npm/lifecycle_scripts/__test__.jsonc
+++ b/tests/specs/npm/lifecycle_scripts/__test__.jsonc
@@ -64,12 +64,17 @@
},
{
// should not warn
- "args": "install -e all_lifecycles.js",
+ "args": "run all_lifecycles_global.js",
"output": ""
+ },
+ {
+ // should warn still
+ "args": "install -e all_lifecycles.js",
+ "output": "all_lifecycles_not_run_global_cached.out"
}
]
},
- "only_warns_first": {
+ "only_warns_first_run": {
"steps": [
{
// without running scripts (should warn)
@@ -82,6 +87,11 @@
"args": "run all_lifecycles.js",
"output": "only_warns_first2.out",
"exitCode": 1
+ },
+ {
+ // should warn because this is an explicit install
+ "args": "install -e all_lifecycles.js",
+ "output": "warns_again_on_install.out"
}
]
},
diff --git a/tests/specs/npm/lifecycle_scripts/all_lifecycles_global.js b/tests/specs/npm/lifecycle_scripts/all_lifecycles_global.js
new file mode 100644
index 000000000..eccf11a6d
--- /dev/null
+++ b/tests/specs/npm/lifecycle_scripts/all_lifecycles_global.js
@@ -0,0 +1,3 @@
+try {
+ const _ = await import("npm:@denotest/node-lifecycle-scripts");
+} catch (_) {}
diff --git a/tests/specs/npm/lifecycle_scripts/all_lifecycles_not_run_global_cached.out b/tests/specs/npm/lifecycle_scripts/all_lifecycles_not_run_global_cached.out
new file mode 100644
index 000000000..789c9346a
--- /dev/null
+++ b/tests/specs/npm/lifecycle_scripts/all_lifecycles_not_run_global_cached.out
@@ -0,0 +1,7 @@
+Warning The following packages contained npm lifecycle scripts (preinstall/install/postinstall) that were not executed:
+┠─ npm:@denotest/node-lifecycle-scripts@1.0.0
+┃
+┠─ This may cause the packages to not work correctly.
+┠─ Lifecycle scripts are only supported when using a `node_modules` directory.
+┠─ Enable it in your deno config file:
+┖─ "nodeModulesDir": "auto"
diff --git a/tests/specs/npm/lifecycle_scripts/warns_again_on_install.out b/tests/specs/npm/lifecycle_scripts/warns_again_on_install.out
new file mode 100644
index 000000000..fe7eedc56
--- /dev/null
+++ b/tests/specs/npm/lifecycle_scripts/warns_again_on_install.out
@@ -0,0 +1,6 @@
+Warning The following packages contained npm lifecycle scripts (preinstall/install/postinstall) that were not executed:
+┠─ npm:@denotest/node-lifecycle-scripts@1.0.0
+┃
+┠─ This may cause the packages to not work correctly.
+┖─ To run lifecycle scripts, use the `--allow-scripts` flag with `deno install`:
+ deno install --allow-scripts=npm:@denotest/node-lifecycle-scripts@1.0.0