From c3f2f73230d6fdbf8ee8fcf0c8d16e2d5a9c40f0 Mon Sep 17 00:00:00 2001 From: Richard Hurt Date: Wed, 27 Apr 2022 14:04:47 -0400 Subject: [PATCH 1/2] Update stack-diff diff * add more details to the README to show the user it's possible to make the stack-diff output more pretty * add the ability to use `icdiff` * correct a problem on macOS where the `type` command doesn't have a "-p" flag --- README.md | 5 +++++ lib/stack-functions | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b9a6af43..38c3f7d4 100644 --- a/README.md +++ b/README.md @@ -148,6 +148,11 @@ postgres02 DELETE_COMPLETE 2011-05-23T15:47:44Z NEVER_UPDATED NOT_NESTED * [bash](https://www.gnu.org/software/bash/) * [jq-1.4](http://stedolan.github.io/jq/download/) or later (for stack-diff) +### Optional Packages + +* [colordiff](https://www.colordiff.org/) to show stack-diff in color +* [icdiff](https://github.com/jeffkaufman/icdiff) to show stack-diff in color and side-by-side + ### Installation As shown below, you may simply clone the GitHub repo and source the files required. diff --git a/lib/stack-functions b/lib/stack-functions index e1c4f904..058bc6b1 100644 --- a/lib/stack-functions +++ b/lib/stack-functions @@ -840,7 +840,9 @@ _bma_stack_diff_template() { if ! aws cloudformation describe-stacks --stack-name "$stack" 1>/dev/null; then return 1; fi - if [ "x$( type -P colordiff )" != "x" ]; then + if [ "x$( command -v icdiff )" != "x" ]; then + local DIFF_CMD=icdiff + elif [ "x$( command -v colordiff )" != "x" ]; then local DIFF_CMD=colordiff else local DIFF_CMD=diff @@ -876,7 +878,9 @@ _bma_stack_diff_params() { if [ ! -f "$params" ]; then return 1 fi - if [ "x$( type -P colordiff )" != "x" ]; then + if [ "x$( command -v icdiff )" != "x" ]; then + local DIFF_CMD=icdiff + elif [ "x$( command -v colordiff )" != "x" ]; then local DIFF_CMD=colordiff else local DIFF_CMD=diff From 4e9d717a583ce55ab3c36053ac7bd2512eb49ced Mon Sep 17 00:00:00 2001 From: Mike Bailey Date: Wed, 4 May 2022 13:36:10 +1000 Subject: [PATCH 2/2] Simplify if statements --- lib/stack-functions | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/stack-functions b/lib/stack-functions index 058bc6b1..5e4d3752 100644 --- a/lib/stack-functions +++ b/lib/stack-functions @@ -840,9 +840,9 @@ _bma_stack_diff_template() { if ! aws cloudformation describe-stacks --stack-name "$stack" 1>/dev/null; then return 1; fi - if [ "x$( command -v icdiff )" != "x" ]; then + if command -v icdiff; then local DIFF_CMD=icdiff - elif [ "x$( command -v colordiff )" != "x" ]; then + elif command -v colordiff; then local DIFF_CMD=colordiff else local DIFF_CMD=diff @@ -878,9 +878,9 @@ _bma_stack_diff_params() { if [ ! -f "$params" ]; then return 1 fi - if [ "x$( command -v icdiff )" != "x" ]; then + if command -v icdiff; then local DIFF_CMD=icdiff - elif [ "x$( command -v colordiff )" != "x" ]; then + elif command -v colordiff; then local DIFF_CMD=colordiff else local DIFF_CMD=diff