Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use node-semver Version const constructor #2000

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.135"
once_cell = "1.19.0"
log = { version = "0.4", features = ["std"] }
node-semver = "2"
node-semver = "2.2"
clap = { version = "4.5.24", features = ["color", "derive", "wrap_help"] }
clap_complete = "4.5.41"
mockito = { version = "0.31.1", optional = true }
Expand Down
11 changes: 2 additions & 9 deletions crates/volta-core/src/run/npx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,8 @@ use crate::error::{ErrorKind, Fallible};
use crate::platform::{Platform, System};
use crate::session::{ActivityKind, Session};
use node_semver::Version;
use once_cell::sync::Lazy;

static REQUIRED_NPM_VERSION: Lazy<Version> = Lazy::new(|| Version {
major: 5,
minor: 2,
patch: 0,
build: vec![],
pre_release: vec![],
});
const REQUIRED_NPM_VERSION: Version = Version::new(5, 2, 0);

/// Build a `ToolCommand` for npx
pub(super) fn command(args: &[OsString], session: &mut Session) -> Fallible<Executor> {
Expand All @@ -41,7 +34,7 @@ pub(super) fn execution_context(
// If the npm version is lower than the minimum required, we can show a helpful error
// message instead of a 'command not found' error.
let active_npm = image.resolve_npm()?;
if active_npm.value < *REQUIRED_NPM_VERSION {
if active_npm.value < REQUIRED_NPM_VERSION {
return Err(ErrorKind::NpxNotAvailable {
version: active_npm.value.to_string(),
}
Expand Down
10 changes: 5 additions & 5 deletions src/command/list/human.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,11 +403,11 @@ mod tests {

use super::*;

static NODE_12: Lazy<Version> = Lazy::new(|| Version::from((12, 2, 0)));
static NODE_11: Lazy<Version> = Lazy::new(|| Version::from((11, 9, 0)));
static NODE_10: Lazy<Version> = Lazy::new(|| Version::from((10, 15, 3)));
static YARN_VERSION: Lazy<Version> = Lazy::new(|| Version::from((1, 16, 0)));
static NPM_VERSION: Lazy<Version> = Lazy::new(|| Version::from((6, 13, 1)));
const NODE_12: Version = Version::new(12, 2, 0);
const NODE_11: Version = Version::new(11, 9, 0);
const NODE_10: Version = Version::new(10, 15, 3);
const YARN_VERSION: Version = Version::new(1, 16, 0);
const NPM_VERSION: Version = Version::new(6, 13, 1);
static PROJECT_PATH: Lazy<PathBuf> = Lazy::new(|| PathBuf::from("~/path/to/project.json"));

mod active {
Expand Down
8 changes: 4 additions & 4 deletions src/command/list/plain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ mod tests {

use crate::command::list::PackageDetails;

static NODE_VERSION: Lazy<Version> = Lazy::new(|| Version::from((12, 4, 0)));
static TYPESCRIPT_VERSION: Lazy<Version> = Lazy::new(|| Version::from((3, 4, 1)));
static NPM_VERSION: Lazy<Version> = Lazy::new(|| Version::from((6, 13, 4)));
static YARN_VERSION: Lazy<Version> = Lazy::new(|| Version::from((1, 16, 0)));
const NODE_VERSION: Version = Version::new(12, 4, 0);
const TYPESCRIPT_VERSION: Version = Version::new(3, 4, 1);
const NPM_VERSION: Version = Version::new(6, 13, 4);
const YARN_VERSION: Version = Version::new(1, 16, 0);
static PROJECT_PATH: Lazy<PathBuf> = Lazy::new(|| PathBuf::from("/a/b/c"));

mod node {
Expand Down