-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake.bat
112 lines (77 loc) · 2.05 KB
/
make.bat
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
@echo off
rem # =================================================================
rem #
rem # Work of the U.S. Department of Defense, Defense Digital Service.
rem # Released as open source under the MIT License. See LICENSE file.
rem #
rem # =================================================================
rem isolate changes to local environment
setlocal
rem create local bin folder if it doesn't exist
if not exist "%~dp0bin" (
mkdir %~dp0bin
)
rem update PATH to include local bin folder
PATH=%~dp0bin;%PATH%
rem set common variables for targets
set "USAGE=Usage: %~n0 [clean|fmt|format_terraform|help|imports|staticcheck|tidy|update_docs]"
rem if no target, then print usage and exit
if [%1]==[] (
echo|set /p="%USAGE%"
exit /B 1
)
if %1%==clean (
REM remove bin directory
if exist %~dp0bin (
rd /s /q %~dp0bin
)
REM remove temp directory
if exist %~dp0temp (
rd /s /q %~dp0temp
)
exit /B 0
)
if %1%==fmt (
go fmt ./test ./pkg/tools
exit /B 0
)
if %1%==format_terraform (
where terraform >nul 2>&1 || (
echo|set /p="terraform is missing."
exit /B 1
)
powershell "%~dp0powershell\format-terraform.ps1"
exit /B 0
)
if %1%==help (
echo|set /p="%USAGE%"
exit /B 1
)
if %1%==imports (
if not exist "%~dp0bin\goimports.exe" (
go build -o bin/goimports.exe golang.org/x/tools/cmd/goimports
)
.\bin\goimports.exe -w -local github.com/gruntwork-io/terratest,github.com/aws/aws-sdk-go,github.com/dod-iac ./test ./pkg/tools
exit /B 0
)
if %1%==staticcheck (
if not exist "%~dp0bin\staticcheck.exe" (
go build -o bin/staticcheck.exe honnef.co/go/tools/cmd/staticcheck
)
.\bin\staticcheck.exe -checks all ./test
exit /B 0
)
if %1%==tidy (
go mod tidy
exit /B 0
)
if %1%==update_docs (
where terraform-docs >nul 2>&1 || (
echo|set /p="terraform-docs is missing/"
exit /B 1
)
powershell "%~dp0powershell\update-docs.ps1"
exit /B 0
)
echo|set /p="%USAGE%"
exit /B 1