File tree Expand file tree Collapse file tree 6 files changed +41
-0
lines changed
Expand file tree Collapse file tree 6 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ # # after hook
2+ # #
3+ # # Any code here will be placed inside an `after_hook()` function and called
4+ # # after running any command.
5+ # #
6+ # # You can safely delete this file if you do not need it.
7+ echo " Thank you for using my script"
Original file line number Diff line number Diff line change 1+ # # before hook
2+ # #
3+ # # Any code here will be placed inside a `before_hook()` function and called
4+ # # before running any command (but after processing its arguments).
5+ # #
6+ # # You can safely delete this file if you do not need it.
7+ inspect_args
Original file line number Diff line number Diff line change 2929 help : Add a help command, in addition to the standard --help flag.
3030 handler : Bashly::Libraries::Help
3131
32+ hooks :
33+ help : Add placeholders for before/after hooks which are executed before/after any command.
34+ files :
35+ - source : " hooks/before.sh"
36+ target : " %{user_source_dir}/before.%{user_ext}"
37+ - source : " hooks/after.sh"
38+ target : " %{user_source_dir}/after.%{user_ext}"
39+
3240lib :
3341 help : |-
3442 Create the lib directory for any additional user scripts.
Original file line number Diff line number Diff line change 1+ created spec/tmp/src/before.sh
2+ created spec/tmp/src/after.sh
Original file line number Diff line number Diff line change @@ -17,6 +17,10 @@ config
1717help
1818 Add a help command, in addition to the standard --help flag.
1919
20+ hooks
21+ Add placeholders for before/after hooks which are executed before/after any
22+ command.
23+
2024lib
2125 Create the lib directory for any additional user scripts.
2226 All *.sh scripts in this directory will be included in the final bash script.
Original file line number Diff line number Diff line change 9494 end
9595 end
9696
97+ context 'with hooks command' do
98+ let ( :before_hook_file ) { "#{ source_dir } /before.sh" }
99+ let ( :after_hook_file ) { "#{ source_dir } /after.sh" }
100+
101+ before { reset_tmp_dir init : true }
102+
103+ it 'copies before.sh and after.sh to the user space' do
104+ expect { subject . execute %w[ add hooks ] } . to output_approval ( 'cli/add/hooks_command' )
105+ expect ( File ) . to exist ( before_hook_file )
106+ expect ( File ) . to exist ( after_hook_file )
107+ end
108+ end
109+
97110 context 'with lib command' do
98111 let ( :lib_file ) { "#{ source_dir } /lib/sample_function.sh" }
99112
You can’t perform that action at this time.
0 commit comments