1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-21 23:04:45 -05:00

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.
This commit is contained in:
Nathan Whitaker 2024-09-26 10:13:33 -07:00 committed by GitHub
parent 13c53d9727
commit 543c687c34
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 37 additions and 3 deletions

View file

@ -548,6 +548,8 @@ pub struct LifecycleScriptsConfig {
pub allowed: PackagesAllowedScripts,
pub initial_cwd: PathBuf,
pub root_dir: PathBuf,
/// Part of an explicit `deno install`
pub explicit_install: bool,
}
#[derive(Debug, Clone, Eq, PartialEq, Default)]

View file

@ -1686,6 +1686,12 @@ impl CliOptions {
allowed: self.flags.allow_scripts.clone(),
initial_cwd: self.initial_cwd.clone(),
root_dir: self.workspace().root_dir_path(),
explicit_install: matches!(
self.sub_command(),
DenoSubcommand::Install(_)
| DenoSubcommand::Cache(_)
| DenoSubcommand::Add(_)
),
}
}
}

View file

@ -111,7 +111,7 @@ impl<'a> LifecycleScripts<'a> {
.push((package, package_path.into_owned()));
}
} else if !self.strategy.has_run(package)
&& !self.strategy.has_warned(package)
&& (self.config.explicit_install || !self.strategy.has_warned(package))
{
self
.packages_with_scripts_not_run

View file

@ -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"
}
]
},

View file

@ -0,0 +1,3 @@
try {
const _ = await import("npm:@denotest/node-lifecycle-scripts");
} catch (_) {}

View file

@ -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"

View file

@ -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