@@ -40,17 +40,23 @@ pub fn check(build: &mut Build) {
40
40
panic ! ( "PATH contains invalid character '\" '" ) ;
41
41
}
42
42
}
43
- let mut need_cmd = |cmd : & OsStr | {
44
- if !checked. insert ( cmd. to_owned ( ) ) {
45
- return
46
- }
43
+ let have_cmd = |cmd : & OsStr | {
47
44
for path in env:: split_paths ( & path) . map ( |p| p. join ( cmd) ) {
48
45
if fs:: metadata ( & path) . is_ok ( ) ||
49
46
fs:: metadata ( path. with_extension ( "exe" ) ) . is_ok ( ) {
50
- return
47
+ return Some ( path ) ;
51
48
}
52
49
}
53
- panic ! ( "\n \n couldn't find required command: {:?}\n \n " , cmd) ;
50
+ return None ;
51
+ } ;
52
+
53
+ let mut need_cmd = |cmd : & OsStr | {
54
+ if !checked. insert ( cmd. to_owned ( ) ) {
55
+ return
56
+ }
57
+ if have_cmd ( cmd) . is_none ( ) {
58
+ panic ! ( "\n \n couldn't find required command: {:?}\n \n " , cmd) ;
59
+ }
54
60
} ;
55
61
56
62
// If we've got a git directory we're gona need git to update
@@ -75,8 +81,13 @@ pub fn check(build: &mut Build) {
75
81
76
82
need_cmd ( "python" . as_ref ( ) ) ;
77
83
78
- // If a manual nodejs was added to the config,
79
- // of if a nodejs install is detected through config, use it.
84
+ // Look for the nodejs command, needed for emscripten testing
85
+ if let Some ( node) = have_cmd ( "node" . as_ref ( ) ) {
86
+ build. config . nodejs = Some ( node) ;
87
+ } else if let Some ( node) = have_cmd ( "nodejs" . as_ref ( ) ) {
88
+ build. config . nodejs = Some ( node) ;
89
+ }
90
+
80
91
if let Some ( ref s) = build. config . nodejs {
81
92
need_cmd ( s. as_ref ( ) ) ;
82
93
}
0 commit comments