-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustomize.sh
40 lines (25 loc) · 1.43 KB
/
customize.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env bash
current_dir=$(basename "$(pwd)")
MODULE_ID="${current_dir#sneat-mod-}"
echo "Module id: $MODULE_ID"
# ======== BEGIN: Customization of Go related files & directories ========
# Renames module name in go.mod file using actual module id taken from $MODULE_ID environment variable
sed -i '' "s/sneat-mod-module/sneat-mod-$MODULE_ID/g" go.mod
# Renames module sub-directories using actual module id taken from $MODULE_ID environment variable
for dir in go/module/*module; do mv "$dir" "${dir%module}$MODULE_ID"; done
# Replace 4module with actual module id taken from $MODULE_ID environment variable
find "go/module" -type f -exec sed -i '' "s/4module/4$MODULE_ID/g" {} +
# Changes package name "module" to actual module id taken from $MODULE_ID environment variable
find "go/module" -type f -name "*.go" -exec sed -i '' "s/package module/package $MODULE_ID/g" {} +
# Replace {MODULE_ID} with actual module id taken from $MODULE_ID environment variable
find "go/module" -type f -name "*.go" -exec sed -i '' "s/{MODULE_ID}/$MODULE_ID/g" {} +
# Renames module directory using actual module id taken from $MODULE_ID environment variable
mv go/module go/"$MODULE_ID"
# ======== END: Customization of Go related files & directories ========
# ======== BEGIN: Clean-up ========
# Replace README.md with README-MODULE.md
mv README-MODULE.md README.md
# Remove customization script
rm customize.sh
git add .
# ======== END: Clean-up ========