@@ -6,15 +6,13 @@ use gleam_core::{
6
6
paths:: ProjectPaths ,
7
7
} ;
8
8
9
- #[ cfg( target_os = "windows" ) ]
10
- static ENTRYPOINT_FILENAME : & str = "entrypoint.ps1" ;
11
- #[ cfg( not( target_os = "windows" ) ) ]
12
- static ENTRYPOINT_FILENAME : & str = "entrypoint.sh" ;
9
+ static ENTRYPOINT_FILENAME_POWERSHELL : & str = "entrypoint.ps1" ;
10
+ static ENTRYPOINT_FILENAME_BOURNE_SHELL : & str = "entrypoint.sh" ;
13
11
14
- # [ cfg ( target_os = "windows" ) ]
15
- static ENTRYPOINT_TEMPLATE : & str = include_str ! ( "../templates/erlang-shipment-entrypoint.ps1" ) ;
16
- # [ cfg ( not ( target_os = "windows" ) ) ]
17
- static ENTRYPOINT_TEMPLATE : & str = include_str ! ( "../templates/erlang-shipment-entrypoint.sh" ) ;
12
+ static ENTRYPOINT_TEMPLATE_POWERSHELL : & str =
13
+ include_str ! ( "../templates/erlang-shipment-entrypoint.ps1" ) ;
14
+ static ENTRYPOINT_TEMPLATE_BOURNE_SHELL : & str =
15
+ include_str ! ( "../templates/erlang-shipment-entrypoint.sh" ) ;
18
16
19
17
// TODO: start in embedded mode
20
18
// TODO: test
@@ -78,23 +76,36 @@ pub(crate) fn erlang_shipment(paths: &ProjectPaths) -> Result<()> {
78
76
}
79
77
}
80
78
81
- // Write entrypoint script
82
- let entrypoint = out. join ( ENTRYPOINT_FILENAME ) ;
83
- let text =
84
- ENTRYPOINT_TEMPLATE . replace ( "$PACKAGE_NAME_FROM_GLEAM" , & built. root_package . config . name ) ;
85
- crate :: fs:: write ( & entrypoint, & text) ?;
86
- crate :: fs:: make_executable ( & entrypoint) ?;
79
+ for ( entrypoint_filename, entrypoint_template_path) in [
80
+ (
81
+ ENTRYPOINT_FILENAME_POWERSHELL ,
82
+ ENTRYPOINT_TEMPLATE_POWERSHELL ,
83
+ ) ,
84
+ (
85
+ ENTRYPOINT_FILENAME_BOURNE_SHELL ,
86
+ ENTRYPOINT_TEMPLATE_BOURNE_SHELL ,
87
+ ) ,
88
+ ] {
89
+ // Write entrypoint script
90
+ let entrypoint = out. join ( entrypoint_filename) ;
91
+ let text = entrypoint_template_path
92
+ . replace ( "$PACKAGE_NAME_FROM_GLEAM" , & built. root_package . config . name ) ;
93
+ crate :: fs:: write ( & entrypoint, & text) ?;
94
+ crate :: fs:: make_executable ( & entrypoint) ?;
95
+ }
87
96
88
97
crate :: cli:: print_exported ( & built. root_package . config . name ) ;
89
98
90
99
println ! (
91
100
"
92
- Your Erlang shipment has been generated to {out}.
93
-
94
- It can be copied to a compatible server with Erlang installed and run with
95
- the {ENTRYPOINT_FILENAME} script.
101
+ Your Erlang shipment has been generated to {out}."
102
+ ) ;
96
103
97
- {entrypoint}
104
+ println ! (
105
+ "
106
+ It can be copied to a compatible server with Erlang installed and run with one of the following scripts:
107
+ - {ENTRYPOINT_FILENAME_POWERSHELL} (PowerShell script)
108
+ - {ENTRYPOINT_FILENAME_BOURNE_SHELL} (Bourne Shell script)
98
109
" ,
99
110
) ;
100
111
0 commit comments