Last active
December 6, 2019 15:12
-
-
Save wingkwong/bb33ad9985d93f9b324cf8b6465ee507 to your computer and use it in GitHub Desktop.
Relocate golang boilerplate packages using Taskfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '2' | |
tasks: | |
relocate: | |
cmds: | |
- echo " *** Relocating packages to {{.TARGET_PATH}} ***" | |
- task: replace-string | |
vars: { | |
SOURCE_STR: "{{.PACKAGE_NAME}}", | |
TARGET_STG: "{{.TARGET_PATH}}" | |
} | |
- task: replace-string | |
vars: { | |
SOURCE_STR: "{{.PROJECT_NAME}}", | |
TARGET_STG: "{{.TARGET_PROJECTNAME}}" | |
} | |
- echo " *** Completed *** " | |
silent: true | |
vars: | |
GITHUB: "github.com" | |
PROJECT_NAME_DIR: | |
sh: echo $(basename "$(dirname "$(pwd)")") | |
PROJECT_NAME: | |
sh: echo $(basename "$(pwd)" | sed -e 's/[\/&]/\\&/g') | |
PACKAGE_NAME: | |
sh: echo "{{.GITHUB}}/{{.PROJECT_NAME_DIR}}/{{.PROJECT_NAME}}" | sed -e 's/[\/&]/\\&/g' | |
TARGET_PATH: | |
sh: echo "{{.TARGET}}" | sed -e 's/[\/&]/\\&/g' | |
TARGET_PROJECTNAME: | |
sh: basename "dirname {{.TARGET_PATH}}" | sed -e 's/[\/&]/\\&/g' | |
preconditions: | |
- sh: "[ {{.TARGET}} != '' ]" | |
replace-string: | |
cmds: | |
- grep -rlI '{{.SOURCE_STR}}' --include=*.{go,json} ./ | xargs -I@ sed -i '' 's/{{.SOURCE_STR}}/{{.TARGET_STG}}/g' @ | |
silent: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment