Skip to content
This repository was archived by the owner on Aug 15, 2025. It is now read-only.

Commit 4439815

Browse files
authored
Switching from glob to wax to fix symlink follow issue (#89)
1 parent ff5241e commit 4439815

File tree

4 files changed

+66
-18
lines changed

4 files changed

+66
-18
lines changed

Cargo.lock

Lines changed: 45 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ dirs = "6.0.0"
5151
fs_extra = "1.3.0"
5252
futures = "0.3.31"
5353
futures-util = "0.3.31"
54-
glob = "0.3.2"
5554
heck = "0.5.0"
5655
http = "1.2.0"
5756
http-body-util = "0.1.2"
@@ -107,6 +106,7 @@ uuid = "1.13.2"
107106
version-compare = "0.2.0"
108107
wac-graph = "=0.6.1"
109108
walkdir = "2.5.0"
109+
wax = "0.6.0"
110110
wit-bindgen-rust = "=0.26.0"
111111
wit-encoder = "=0.221.2"
112112
wit-parser = "=0.221.3"

wasm-rpc-stubgen/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ clap = { workspace = true }
3838
colored = { workspace = true }
3939
dir-diff = { workspace = true }
4040
fs_extra = { workspace = true }
41-
glob = { workspace = true }
4241
heck = { workspace = true }
4342
id-arena = { workspace = true }
4443
indexmap = { workspace = true }
@@ -61,6 +60,7 @@ tokio = { workspace = true }
6160
toml = { workspace = true }
6261
wac-graph = { workspace = true }
6362
walkdir = { workspace = true }
63+
wax = { workspace = true }
6464
wit-bindgen-rust = { workspace = true }
6565
wit-encoder = { workspace = true }
6666
wit-parser = { workspace = true }

wasm-rpc-stubgen/src/commands/app.rs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use crate::{commands, naming, WasmRpcOverride};
2222
use anyhow::{anyhow, bail, Context, Error};
2323
use colored::control::SHOULD_COLORIZE;
2424
use colored::Colorize;
25-
use glob::{glob_with, MatchOptions};
2625
use golem_wasm_rpc::WASM_RPC_VERSION;
2726
use itertools::Itertools;
2827
use serde::Serialize;
@@ -35,6 +34,7 @@ use std::path::{Path, PathBuf};
3534
use std::process::Command;
3635
use std::time::SystemTime;
3736
use walkdir::WalkDir;
37+
use wax::{Glob, LinkBehavior, WalkBehavior};
3838

3939
pub struct Config<CPE: ComponentPropertiesExtensions> {
4040
pub app_source_mode: ApplicationSourceMode,
@@ -1289,25 +1289,29 @@ fn compile_and_collect_globs(root_dir: &Path, globs: &[String]) -> Result<Vec<Pa
12891289
globs
12901290
.iter()
12911291
.map(|pattern| {
1292-
glob_with(
1293-
&format!("{}/{}", root_dir.to_string_lossy(), pattern),
1294-
MatchOptions {
1295-
case_sensitive: true,
1296-
require_literal_separator: false,
1297-
require_literal_leading_dot: true,
1292+
Glob::new(pattern)
1293+
.with_context(|| format!("Failed to compile glob expression: {}", pattern))
1294+
})
1295+
.collect::<Result<Vec<_>, _>>()
1296+
.map_err(|err| anyhow!(err))?
1297+
.iter()
1298+
.flat_map(|glob| {
1299+
glob.walk_with_behavior(
1300+
root_dir,
1301+
WalkBehavior {
1302+
link: LinkBehavior::ReadFile,
1303+
..WalkBehavior::default()
12981304
},
12991305
)
1300-
.with_context(|| format!("Failed to compile glob expression: {}", pattern))
1306+
.collect::<Vec<_>>()
1307+
})
1308+
.map(|walk_item| {
1309+
walk_item
1310+
.map(|entry| entry.path().to_path_buf())
1311+
.with_context(|| "Failed to get path from item when evaluating glob expressions")
13011312
})
13021313
.collect::<Result<Vec<_>, _>>()
13031314
.map_err(|err| anyhow!(err))
1304-
.and_then(|paths| {
1305-
paths
1306-
.into_iter()
1307-
.flatten()
1308-
.collect::<Result<Vec<_>, _>>()
1309-
.map_err(|err| anyhow!(err))
1310-
})
13111315
}
13121316

13131317
fn create_generated_base_wit<CPE: ComponentPropertiesExtensions>(

0 commit comments

Comments
 (0)