File tree Expand file tree Collapse file tree 3 files changed +18
-3
lines changed
Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Original file line number Diff line number Diff line change 3838 hooks :
3939 - id : packer_fmt
4040 - id : packer_validate
41+ args : [--no-cd] # Optionally disable changing working directory
4142` ` `
4243
4344## Contributing ##
Original file line number Diff line number Diff line change @@ -22,10 +22,18 @@ util::get_unique_directory_paths "${FILES[@]}"
2222error=0
2323
2424for path in " ${UNIQUE_PATHS[@]} " ; do
25- pushd " $path " > /dev/null
25+ if [[ $NO_CD -eq 1 ]]; then
26+ packer init -- " $path " > /dev/null
27+ packer validate " ${ARGS[@]} " -- " $path "
28+ lerror=$?
29+ else
30+ pushd " $path " > /dev/null
31+ packer init . > /dev/null
32+ packer validate " ${ARGS[@]} " .
33+ lerror=$?
34+ fi
2635
27- packer init . > /dev/null
28- if ! packer validate " ${ARGS[@]} " . ; then
36+ if [[ $lerror -ne 0 ]]; then
2937 error=1
3038 echo
3139 echo " Failed path: $path "
Original file line number Diff line number Diff line change @@ -9,14 +9,20 @@ set -o pipefail
99# Globals:
1010# ARGS
1111# FILES
12+ # NO_CD
1213# ######################################
1314function util::parse_cmdline() {
1415 # Global variable arrays
1516 ARGS=()
1617 FILES=()
18+ export NO_CD=0
1719
1820 while (( "$# ")) ; do
1921 case " $1 " in
22+ --no-cd)
23+ NO_CD=1
24+ shift
25+ ;;
2026 -* )
2127 if [ -f " $1 " ]; then
2228 FILES+=(" $1 " )
You can’t perform that action at this time.
0 commit comments