Skip to content

Commit 1869102

Browse files
committed
refactor: make version check resiliant againt non stable versions
1 parent 097a7ca commit 1869102

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/bsconfig.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,17 @@ pub fn read(path: String) -> Config {
245245
}
246246

247247
fn check_if_rescript11_or_higher(version: &str) -> bool {
248-
version.split('.').next().unwrap().parse::<usize>().unwrap() >= 11
248+
// Non stable rescript versions might contain non-numeric characters
249+
let filter_non_number_chars = |s: &str| s.chars().filter(|c| c.is_numeric()).collect::<String>();
250+
251+
version
252+
.split('.')
253+
.next()
254+
.map(filter_non_number_chars)
255+
.unwrap()
256+
.parse::<usize>()
257+
.unwrap()
258+
>= 11
249259
}
250260

251261
fn namespace_from_package_name(package_name: &str) -> String {

0 commit comments

Comments
 (0)