From b5b331e31ab1c46b70225d09d62703692985255a Mon Sep 17 00:00:00 2001 From: David Sherret Date: Fri, 24 Feb 2023 21:16:26 -0500 Subject: [PATCH] fix(npm): skip analyzing more specifiers in package.json (#17938) --- cli/args/package_json.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cli/args/package_json.rs b/cli/args/package_json.rs index 97fb97f0bb..301d1b8bae 100644 --- a/cli/args/package_json.rs +++ b/cli/args/package_json.rs @@ -44,8 +44,13 @@ pub fn get_local_package_json_version_reqs( ) -> Result<(), AnyError> { if let Some(deps) = deps { for (key, value) in deps { - if value.starts_with("workspace:") { - // skip workspace specifiers for now + if value.starts_with("workspace:") + || value.starts_with("file:") + || value.starts_with("git:") + || value.starts_with("http:") + || value.starts_with("https:") + { + // skip these specifiers for now continue; } let (name, version_req) = @@ -209,11 +214,15 @@ mod test { } #[test] - fn test_get_local_package_json_version_reqs_skips_workspace_specifiers() { + fn test_get_local_package_json_version_reqs_skips_certain_specifiers() { let mut package_json = PackageJson::empty(PathBuf::from("/package.json")); package_json.dependencies = Some(HashMap::from([ ("test".to_string(), "1".to_string()), ("work".to_string(), "workspace:1.1.1".to_string()), + ("file".to_string(), "file:something".to_string()), + ("git".to_string(), "git:something".to_string()), + ("http".to_string(), "http://something".to_string()), + ("https".to_string(), "https://something".to_string()), ])); let result = get_local_package_json_version_reqs(&package_json).unwrap(); assert_eq!(