diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-10-03 19:10:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-03 19:10:53 +0200 |
commit | 5b097fd7e5224db6de65847a604f5c60a93667a0 (patch) | |
tree | 7859797288148beca4c609b3cfd83e3cae001c91 /ext/node/errors.rs | |
parent | 8e1b2fca59d71d2e6ab404238d7b38975adb3665 (diff) |
fix(npm): better error is version is specified after subpath (#16131)
Diffstat (limited to 'ext/node/errors.rs')
-rw-r--r-- | ext/node/errors.rs | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/ext/node/errors.rs b/ext/node/errors.rs index 4b55d1982..929f51e1b 100644 --- a/ext/node/errors.rs +++ b/ext/node/errors.rs @@ -81,23 +81,36 @@ pub fn err_invalid_package_target( } pub fn err_package_path_not_exported( - pkg_path: String, + mut pkg_path: String, subpath: String, maybe_referrer: Option<String>, ) -> AnyError { let mut msg = "[ERR_PACKAGE_PATH_NOT_EXPORTED]".to_string(); + #[cfg(windows)] + { + if !pkg_path.ends_with('\\') { + pkg_path.push('\\'); + } + } + #[cfg(not(windows))] + { + if !pkg_path.ends_with('/') { + pkg_path.push('/'); + } + } + if subpath == "." { msg = format!( - "{} No \"exports\" main defined in {}package.json", + "{} No \"exports\" main defined in '{}package.json'", msg, pkg_path ); } else { - msg = format!("{} Package subpath \'{}\' is not defined by \"exports\" in {}package.json", msg, subpath, pkg_path); + msg = format!("{} Package subpath '{}' is not defined by \"exports\" in '{}package.json'", msg, subpath, pkg_path); }; if let Some(referrer) = maybe_referrer { - msg = format!("{} imported from {}", msg, referrer); + msg = format!("{} imported from '{}'", msg, referrer); } generic_error(msg) |