From 209ad71b4fff1736cc1bcc0c947b2781917fc168 Mon Sep 17 00:00:00 2001 From: bokuweb Date: Sat, 23 Mar 2024 09:59:52 +0900 Subject: [PATCH] fix: report generation --- src/compare.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/compare.ts b/src/compare.ts index bad0f3bf..d9ff36a2 100644 --- a/src/compare.ts +++ b/src/compare.ts @@ -5,6 +5,7 @@ import { Config } from './config'; import * as constants from './constants'; import { workspace } from './path'; import path from 'path/posix'; +import cpy from 'cpy'; const _compare = require('reg-cli'); @@ -16,13 +17,13 @@ export type CompareOutput = { }; export const compare = async (config: Config): Promise => - new Promise(resolve => { + new Promise(async resolve => { const emitter = _compare({ actualDir: path.join(workspace(), constants.ACTUAL_DIR_NAME), expectedDir: path.join(workspace(), constants.EXPECTED_DIR_NAME), diffDir: path.join(workspace(), constants.DIFF_DIR_NAME), json: path.join(workspace(), constants.JSON_NAME), - report: config.reportFilePath, + report: path.join(workspace(), './report.html'), update: false, ignoreChange: true, urlPrefix: '', @@ -32,7 +33,11 @@ export const compare = async (config: Config): Promise => enableAntialias: config.enableAntialias, }); - emitter.on('complete', async result => { + if (config.reportFilePath) { + await cpy(workspace(), config.reportFilePath); + } + + emitter.on('complete', result => { log.debug('compare result', result); log.info('Comparison Complete'); log.info(chalk.red(' Changed items: ' + result.failedItems.length));