File tree Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Expand file tree Collapse file tree 3 files changed +19
-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 11#! /usr/bin/env bash
22
3+ set -x
34set -o nounset
45set -o errexit
56set -o pipefail
@@ -22,10 +23,18 @@ util::get_unique_directory_paths "${FILES[@]}"
2223error=0
2324
2425for path in " ${UNIQUE_PATHS[@]} " ; do
25- pushd " $path " > /dev/null
26+ if [[ $NO_CD -eq 1 ]]; then
27+ packer init -- " $path " > /dev/null
28+ packer validate " ${ARGS[@]} " -- " $path "
29+ lerror=$?
30+ else
31+ pushd " $path " > /dev/null
32+ packer init . > /dev/null
33+ packer validate " ${ARGS[@]} " .
34+ lerror=$?
35+ fi
2636
27- packer init . > /dev/null
28- if ! packer validate " ${ARGS[@]} " . ; then
37+ if [[ $lerror -ne 0 ]]; then
2938 error=1
3039 echo
3140 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