File tree Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change 44mod docker_client;
55mod rails_new;
66use rails_new:: { Cli , Commands } ;
7- use std:: { io:: Write , process:: Command } ;
7+ use std:: { io:: Write , process:: Command , io :: ErrorKind } ;
88
99use clap:: Parser ;
1010
@@ -23,22 +23,31 @@ fn main() {
2323
2424 // Run docker build --build-arg RUBY_VERSION=$RUBY_VERSION --build-arg RAILS_VERSION=$RAILS_VERSION -t rails-new-$RUBY_VERSION-$RAILS_VERSION
2525 // passing the content of DOCKERFILE to the command stdin
26- let mut child = DockerClient :: build_image (
26+ let child = DockerClient :: build_image (
2727 & ruby_version,
2828 rails_version,
2929 os_specific:: get_user_id ( ) ,
3030 os_specific:: get_group_id ( ) ,
3131 rebuild,
3232 )
33- . spawn ( )
34- . expect ( "Failed to execute process" ) ;
33+ . spawn ( ) ;
3534
36- let mut stdin = child. stdin . take ( ) . expect ( "Failed to open stdin" ) ;
35+ let mut child_ref = match child {
36+ Ok ( child) => child,
37+ Err ( error) => {
38+ if error. kind ( ) == ErrorKind :: NotFound {
39+ println ! ( "Docker is not installed" ) ;
40+ }
41+ std:: process:: exit ( 1 ) ;
42+ }
43+ } ;
44+
45+ let mut stdin = child_ref. stdin . take ( ) . expect ( "Failed to open stdin" ) ;
3746 std:: thread:: spawn ( move || {
3847 stdin. write_all ( os_specific:: dockerfile_content ( ) ) . unwrap ( ) ;
3948 } ) ;
4049
41- let status = child . wait ( ) . expect ( "failed to wait on child" ) ;
50+ let status = child_ref . wait ( ) . expect ( "failed to wait on child" ) ;
4251
4352 assert ! ( status. success( ) ) ;
4453
You can’t perform that action at this time.
0 commit comments