-
Notifications
You must be signed in to change notification settings - Fork 4
/
setup-jetbrains-gotemplates.sh
executable file
·46 lines (39 loc) · 1.39 KB
/
setup-jetbrains-gotemplates.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
41
42
43
44
45
46
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
GOKOALA_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
cd "${GOKOALA_ROOT}"
traverse_templates() {
# HTML templates
find * -type f -iname "*.go.html" -print0 | while IFS= read -r -d '' file; do
echo "Processing file: $file"
echo "<file url=\"file://\$PROJECT_DIR\$/$file\" dialect=\"HTML\" />" >> ".idea/templateLanguages.xml"
done
# JSON templates
find * -type f -iname "*.go.json" -print0 | while IFS= read -r -d '' file; do
echo "Processing file: $file"
echo "<file url=\"file://\$PROJECT_DIR\$/$file\" dialect=\"JSON\" />" >> ".idea/templateLanguages.xml"
done
# TileJSON templates
find * -type f -iname "*.go.tilejson" -print0 | while IFS= read -r -d '' file; do
echo "Processing file: $file"
echo "<file url=\"file://\$PROJECT_DIR\$/$file\" dialect=\"JSON\" />" >> ".idea/templateLanguages.xml"
done
# XML templates
find * -type f -iname "*.go.xml" -print0 | while IFS= read -r -d '' file; do
echo "Processing file: $file"
echo "<file url=\"file://\$PROJECT_DIR\$/$file\" dialect=\"XML\" />" >> ".idea/templateLanguages.xml"
done
}
mkdir -p ".idea/"
cat << EOF > ".idea/templateLanguages.xml"
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="TemplateDataLanguageMappings">
EOF
traverse_templates
cat << EOF >> ".idea/templateLanguages.xml"
</component>
</project>
EOF