Skip to content

Commit

Permalink
fix: cfg for windows and exclude compile functions for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelramos committed Jul 18, 2024
1 parent 564de43 commit 30985be
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[package]
name = "workspace-node-tools"
version = "1.0.2"
version = "1.0.3"
edition = "2021"
description = "Node workspace version tools"
repository = "https://github.com/websublime/workspace-node-tools"
license = "MIT OR Apache-2.0"
build = "build.rs"
resolver = "2"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
Expand All @@ -15,10 +16,10 @@ path = "src/lib.rs"
execute = "0.2.13"
serde = { version = "1.0.204", features = ["derive"] }
serde_json = "1.0.120"
regex = "1.10.3"
regex = "1.10.5"
wax = { version = "0.6.0", features = ["walk"] }
napi-derive = { version = "2.16.8", optional = true }
napi = { version = "2.16.7", default-features = false, features = ["napi9", "serde-json", "tokio_rt"], optional = true }
napi-derive = { version = "2.16.9", optional = true }
napi = { version = "2.16.8", default-features = false, features = ["napi9", "serde-json", "tokio_rt"], optional = true }
package_json_schema = "0.2.1"
icu = "1.5.0"
version-compare = "0.2"
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
fn main() {
println!("Hello, world!");
}
}
23 changes: 17 additions & 6 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@
#![allow(dead_code)]

use regex::Regex;
use std::env::temp_dir;

#[cfg(test)]
use std::fs::{create_dir, File};
#[cfg(test)]
use std::io::Write;

#[cfg(test)]
#[cfg(not(windows))]
use std::os::unix::fs::PermissionsExt;
use std::path::PathBuf;
use std::process::Command;
use std::process::Stdio;

#[cfg(test)]
use super::manager::PackageManager;
#[cfg(test)]
use std::process::Command;
#[cfg(test)]
use std::process::Stdio;

#[derive(Debug)]
pub struct PackageScopeMetadata {
Expand All @@ -20,8 +27,10 @@ pub struct PackageScopeMetadata {
pub path: Option<String>,
}

#[cfg(test)]
struct Rng(u64);

#[cfg(test)]
impl Rng {
const A: u64 = 6364136223846793005;

Expand Down Expand Up @@ -64,13 +73,14 @@ pub(crate) fn strip_trailing_newline(input: &String) -> String {
.to_string()
}

#[cfg(test)]
pub(crate) fn create_test_monorepo(
package_manager: &PackageManager,
) -> Result<PathBuf, std::io::Error> {
) -> Result<std::path::PathBuf, std::io::Error> {
let mut rng = Rng::from_seed(0);
let rand_string = format!("{:016x}", rng.rand());

let temp_dir = temp_dir();
let temp_dir = std::env::temp_dir();
let monorepo_temp_dir = temp_dir.join(format!("monorepo-{}", rand_string));
let monorepo_package_json = monorepo_temp_dir.join("package.json");

Expand All @@ -83,6 +93,7 @@ pub(crate) fn create_test_monorepo(
create_dir(&monorepo_package_a_dir)?;
create_dir(&monorepo_package_b_dir)?;

#[cfg(not(windows))]
std::fs::set_permissions(&monorepo_temp_dir, std::fs::Permissions::from_mode(0o777))?;

let mut monorepo_package_json_file = File::create(&monorepo_package_json)?;
Expand Down

0 comments on commit 30985be

Please sign in to comment.