fix(npm): package.json auto-discovery should respect --no-config and --no-npm (#17924)

Part of #17916
This commit is contained in:
David Sherret 2023-02-24 13:51:21 -05:00 committed by GitHub
parent 6472afd12b
commit 7ad64283a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 3 deletions

View file

@ -568,7 +568,9 @@ impl CliOptions {
let maybe_config_file = ConfigFile::discover(&flags, &initial_cwd)?;
let mut maybe_package_json = None;
if let Some(config_file) = &maybe_config_file {
if flags.config_flag == ConfigFlag::Disabled || flags.no_npm {
log::debug!("package.json auto-discovery is disabled")
} else if let Some(config_file) = &maybe_config_file {
let specifier = config_file.specifier.clone();
if specifier.scheme() == "file" {
let maybe_stop_at = specifier
@ -582,6 +584,7 @@ impl CliOptions {
} else {
maybe_package_json = discover_package_json(&flags, None)?;
}
let maybe_lock_file =
lockfile::discover(&flags, maybe_config_file.as_ref())?;
Self::new(