Skip to content

Instantly share code, notes, and snippets.

@danyg
Created November 9, 2022 17:08
Show Gist options
  • Save danyg/2b13007926c104e0cffd063d179ce617 to your computer and use it in GitHub Desktop.
Save danyg/2b13007926c104e0cffd063d179ce617 to your computer and use it in GitHub Desktop.
command line helpers
#!/bin/bash
currentBranchName=$(git branch --show-current)
milestone=$1
backupBranchName=BACKUP/${currentBranchName}
if test -z "$milestone"; then #empty
milestone=$(date '+%Y%m%d-%H%M%S')
fi
backupBranchName=BACKUP/${currentBranchName}/${milestone}
git branch -D ${backupBranchName}
git branch ${backupBranchName}
echo "BACKUP Branch created: ${backupBranchName}"
#!/bin/bash
currentBranchName=$(git branch --show-current)
dg.git.backup
git fetch --all
git reset --hard origin/${currentBranchName}
#!/bin/bash
npm_script=$1
src_file_stp1="${test_file/"/test/"/"/lib/"}"
src_file="${src_file_stp1/"_test.exs"/".ex"}"
watched_directory=$(pwd)
do_test() {
echo -e "\n\n running npm run ${npm_script} ...\n\n"
npm run $npm_script
echo -e "\n\nWatching... \n - ${watched_directory}\n\n"
}
do_test
# TODO: this approach of watching all needs to be filter down, so only .ex and .exs triggers it
# inotifywait -m -r -e create -e close_write --format '%w%f' "${watched_directory}" | while read FILEPATH
inotifywait -m -r -e create -e close_write --format '%w%f' "${watched_directory}" | while read FILEPATH; do
# echo "--> ${FILEPATH}"
if [[ "$FILEPATH" =~ ^.*\.[tj]sx?$ ]]; then
if ! [[ "$FILEPATH" =~ ^.*/(out|dist|node_modules)/.*$ ]]; then
# echo "is JS, TS, JSX, TSX"
do_test
# else
# echo "is transpiled or dependency"
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment