From e9064926994a71a85f244dd6f8ca2a7c432a8184 Mon Sep 17 00:00:00 2001 From: Lukas Date: Fri, 9 Aug 2024 22:23:43 +0200 Subject: [PATCH] fix: diff tooling (#151) --- src/commands/diffSnaphots.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/commands/diffSnaphots.ts b/src/commands/diffSnaphots.ts index 5927b32..f48f5cd 100644 --- a/src/commands/diffSnaphots.ts +++ b/src/commands/diffSnaphots.ts @@ -1,4 +1,5 @@ import fs from 'node:fs'; +import path from 'node:path'; import {compareStorageLayouts} from '@bgd-labs/js-utils'; import type {Command} from '@commander-js/extra-typings'; import {adiDiffReports} from '../reports/adi-diff-reports'; @@ -18,6 +19,7 @@ export function addCommand(program: Command) { const to = options.stringMode ? readJsonString(_to) : readJsonFile(_to); const content = await diffReports(from, to); if (options.out) { + fs.mkdirSync(path.dirname(options.out), {recursive: true}); fs.writeFileSync(options.out, content); } else { console.log(content); @@ -36,6 +38,7 @@ export function addCommand(program: Command) { const to = options.stringMode ? readJsonString(_to) : readJsonFile(_to); const content = await adiDiffReports(from, to); if (options.out) { + fs.mkdirSync(path.dirname(options.out), {recursive: true}); fs.writeFileSync(options.out, content); } else { console.log(content); @@ -53,6 +56,7 @@ export function addCommand(program: Command) { const to = readJsonFile(_to); const content = await compareStorageLayouts(from, to); if (options.out) { + fs.mkdirSync(path.dirname(options.out), {recursive: true}); fs.writeFileSync(options.out, content); } else { console.log(content);