@@ -40,17 +40,23 @@ pub fn check(build: &mut Build) {
4040 panic ! ( "PATH contains invalid character '\" '" ) ;
4141 }
4242 }
43- let mut need_cmd = |cmd : & OsStr | {
44- if !checked. insert ( cmd. to_owned ( ) ) {
45- return
46- }
43+ let have_cmd = |cmd : & OsStr | {
4744 for path in env:: split_paths ( & path) . map ( |p| p. join ( cmd) ) {
4845 if fs:: metadata ( & path) . is_ok ( ) ||
4946 fs:: metadata ( path. with_extension ( "exe" ) ) . is_ok ( ) {
50- return
47+ return Some ( path ) ;
5148 }
5249 }
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+ }
5460 } ;
5561
5662 // If we've got a git directory we're gona need git to update
@@ -75,8 +81,13 @@ pub fn check(build: &mut Build) {
7581
7682 need_cmd ( "python" . as_ref ( ) ) ;
7783
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+
8091 if let Some ( ref s) = build. config . nodejs {
8192 need_cmd ( s. as_ref ( ) ) ;
8293 }
0 commit comments