File tree 2 files changed +10
-5
lines changed
2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env python3
2
+ import os
2
3
3
- print ("Hello {{greeting_recipient}}!" )
4
+ print (f "Hello {{greeting_recipient}} from { os . getcwd () } !" )
Original file line number Diff line number Diff line change @@ -107,9 +107,13 @@ macro_rules! bail_if_err {
107
107
} } ;
108
108
}
109
109
110
- fn execute_hook ( hook : & HookFile ) -> Result < ( ) > {
110
+ fn execute_hook ( hook : & HookFile , output_dir : & PathBuf ) -> Result < ( ) > {
111
111
terminal:: bold ( & format ! ( " - {}\n " , hook. name( ) ) ) ;
112
- match StdCommand :: new ( hook. path ( ) ) . status ( ) {
112
+ let mut command = StdCommand :: new ( hook. path ( ) ) ;
113
+ if output_dir. exists ( ) {
114
+ command. current_dir ( output_dir) ;
115
+ }
116
+ match command. status ( ) {
113
117
Ok ( code) => {
114
118
if code. success ( ) {
115
119
Ok ( ( ) )
@@ -155,7 +159,7 @@ fn main() {
155
159
if cli. run_hooks && !pre_gen_hooks. is_empty ( ) {
156
160
terminal:: bold ( "Running pre-gen hooks...\n " ) ;
157
161
for hook in & pre_gen_hooks {
158
- bail_if_err ! ( execute_hook( hook) ) ;
162
+ bail_if_err ! ( execute_hook( hook, & cli . output_dir ) ) ;
159
163
}
160
164
println ! ( ) ;
161
165
}
@@ -168,7 +172,7 @@ fn main() {
168
172
if cli. run_hooks && !post_gen_hooks. is_empty ( ) {
169
173
terminal:: bold ( "Running post-gen hooks...\n " ) ;
170
174
for hook in & post_gen_hooks {
171
- bail_if_err ! ( execute_hook( hook) ) ;
175
+ bail_if_err ! ( execute_hook( hook, & cli . output_dir ) ) ;
172
176
}
173
177
println ! ( ) ;
174
178
}
You can’t perform that action at this time.
0 commit comments