scripts: fix tar esm issue (#48442)

* Update build.ts

Signed-off-by: vagusX <vagusxl@gmail.com>

* Update build.ts

Signed-off-by: vagusX <vagusxl@gmail.com>

---------

Signed-off-by: vagusX <vagusxl@gmail.com>
This commit is contained in:
vagusX 2024-04-14 11:09:47 +08:00 committed by GitHub
parent 72b5263344
commit 0072587f14
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -16,7 +16,6 @@ import { remark } from 'remark';
import remarkGfm from 'remark-gfm';
import remarkHtml from 'remark-html';
import sharp from 'sharp';
import tar from 'tar';
const ROOT_DIR = process.cwd();
const ALI_OSS_BUCKET = 'antd-visual-diff';
@ -106,6 +105,7 @@ async function getBranchLatestRef(branchName: string) {
}
async function downloadBaseSnapshots(ref: string, targetDir: string) {
const tar = await import('tar');
// download imageSnapshotsUrl
const imageSnapshotsUrl = `${ossDomain}/${ref}/imageSnapshots.tar.gz`;
const targzPath = path.resolve(os.tmpdir(), `./${path.basename(targetDir)}.tar.gz`);
@ -350,7 +350,7 @@ async function boot() {
htmlTemplate.replace('{{reportContent}}', reportHtmlStr),
'utf-8',
);
const tar = await import('tar');
await tar.c(
{
gzip: true,