From 7e87a3a35c21f9311e77687149175703365b54f0 Mon Sep 17 00:00:00 2001 From: vagusX Date: Thu, 25 Jul 2024 15:53:57 +0800 Subject: [PATCH] ci: fix img name compatibility --- scripts/visual-diff-capture.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/visual-diff-capture.ts b/scripts/visual-diff-capture.ts index 1167c978ba..127ea74c38 100644 --- a/scripts/visual-diff-capture.ts +++ b/scripts/visual-diff-capture.ts @@ -9,7 +9,7 @@ import fse from 'fs-extra'; import { createServer } from 'http-server'; import { chromium } from 'playwright-chromium'; import type { Browser, BrowserContext, Page } from 'playwright-chromium'; -import loglevel, { log } from 'loglevel'; +import loglevel from 'loglevel'; import type { LogLevelNames } from 'loglevel'; interface VisualDiffConfig { @@ -48,7 +48,7 @@ async function getAllComponentMds(componentName?: string) { dot: false, }); - return mds; + return mds.sort(); } const port = 3001; @@ -138,9 +138,12 @@ class BrowserAuto { await page.click(`.${options.openTriggerClassName}`); } + // ~demos/button-demo-basic -> button-basic + const imgName = `${demoUrl.replace('-demo', '')}.${theme}.png`; + // 保存截图到 ./result 目录 await page.screenshot({ - path: path.join(this.outputDir, `${demoUrl}.${theme}.png`), + path: path.join(this.outputDir, imgName), scale: 'device', type: 'png', fullPage: !options.onlyViewport,