From d696f68efbdf4ca4733dacaae09e6a6c9dac75f2 Mon Sep 17 00:00:00 2001 From: Tom Date: Fri, 31 May 2024 08:55:51 +0100 Subject: [PATCH] f - Launch VSCode diff tool in case of differences - first pass --- lib/approvals.ex | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/approvals.ex b/lib/approvals.ex index 90e0879..8522f32 100644 --- a/lib/approvals.ex +++ b/lib/approvals.ex @@ -54,9 +54,18 @@ defmodule Approvals do received_file_name = Namer.received_name(options) Writer.write(data, received_file_name) + approved_file_name = Namer.approved_name(options) + received_data = File.read!(received_file_name) - approved_data = File.read!(Namer.approved_name(options)) + approved_data = File.read!(approved_file_name) + + cond do + approved_data == received_data -> + true - ExUnit.Assertions.assert(approved_data == received_data) + true -> + System.cmd("code", ["-d", received_file_name, approved_file_name]) + ExUnit.Assertions.assert(approved_data == received_data) + end end end