@@ -232,6 +232,21 @@ function IO:progress() {
232
232
)
233
233
}
234
234
235
+ function IO:countdown(){
236
+ local seconds=${1:- 5}
237
+ local message=${2:- Countdown : }
238
+
239
+ if (( piped)) ; then
240
+ IO:print " $message $seconds seconds"
241
+ else
242
+ for (( i = 0 ; i < "$seconds "; i++ )) ; do
243
+ IO:progress " ${txtInfo} $message $(( seconds - i)) seconds${txtReset} "
244
+ sleep 1
245
+ done
246
+ IO:print " "
247
+ fi
248
+ }
249
+
235
250
# ## interactive
236
251
function IO:confirm() {
237
252
(( force)) && return 0
@@ -351,6 +366,20 @@ function Str:digest() {
351
366
fi
352
367
}
353
368
369
+ # Gha: function should only be run inside of a Github Action
370
+
371
+ function Gha:finish(){
372
+ [[ -z " ${RUNNER_OS:- } " ]] && IO:die " This should only run inside a Github Action, don't run it on your machine"
373
+ git config user.name " Bashew Runner"
374
+ git config user.email " actions@users.noreply.github.com"
375
+ timestamp=$( date -u)
376
+ message=" $timestamp < $script_basename $script_version "
377
+ git add -A
378
+ git commit -m " ${message} " || exit 0
379
+ git pull --rebase
380
+ git push
381
+ exit 0
382
+ }
354
383
355
384
trap " IO:die \" ERROR \$ ? after \$ SECONDS seconds \n\
356
385
\$ {error_prefix} last command : '\$ BASH_COMMAND' \" \
@@ -838,16 +867,16 @@ function Os:beep(){
838
867
}
839
868
840
869
function Script:meta() {
841
- local git_repo_remote=" "
842
- local git_repo_root=" "
843
- local os_kernel=" "
844
- local os_machine=" "
845
- local os_name=" "
846
- local os_version=" "
847
- local script_hash=" ?"
848
- local script_lines=" ?"
849
- local shell_brand=" "
850
- local shell_version=" "
870
+ git_repo_remote=" "
871
+ git_repo_root=" "
872
+ os_kernel=" "
873
+ os_machine=" "
874
+ os_name=" "
875
+ os_version=" "
876
+ script_hash=" ?"
877
+ script_lines=" ?"
878
+ shell_brand=" "
879
+ shell_version=" "
851
880
852
881
script_prefix=$( basename " ${BASH_SOURCE[0]} " .sh)
853
882
script_basename=$( basename " ${BASH_SOURCE[0]} " )
@@ -961,14 +990,22 @@ function Os:tempfile(){
961
990
962
991
function Os:import_env() {
963
992
local env_files
964
- env_files=(
965
- " $script_install_folder /.env"
966
- " $script_install_folder /.$script_prefix .env"
967
- " $script_install_folder /$script_prefix .env"
968
- " ./.env"
969
- " ./.$script_prefix .env"
970
- " ./$script_prefix .env"
971
- )
993
+ if [[ $( pwd) == " $script_install_folder " ]] ; then
994
+ env_files=(
995
+ " $script_install_folder /.env"
996
+ " $script_install_folder /.$script_prefix .env"
997
+ " $script_install_folder /$script_prefix .env"
998
+ )
999
+ else
1000
+ env_files=(
1001
+ " $script_install_folder /.env"
1002
+ " $script_install_folder /.$script_prefix .env"
1003
+ " $script_install_folder /$script_prefix .env"
1004
+ " ./.env"
1005
+ " ./.$script_prefix .env"
1006
+ " ./$script_prefix .env"
1007
+ )
1008
+ fi
972
1009
973
1010
for env_file in " ${env_files[@]} " ; do
974
1011
if [[ -f " $env_file " ]]; then
0 commit comments