From f037567fc5efea4ac650eb324818fe6b556bfcdb Mon Sep 17 00:00:00 2001 From: snomiao Date: Tue, 2 Sep 2025 21:17:27 +0000 Subject: [PATCH] style: Apply Prettier formatting - Fix trailing whitespace - Add missing newlines at end of files --- browser_tests/globalSetupWithI18n.ts | 8 +++---- browser_tests/globalTeardownWithI18n.ts | 4 ++-- browser_tests/i18nSetup.ts | 28 ++++++++++++------------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/browser_tests/globalSetupWithI18n.ts b/browser_tests/globalSetupWithI18n.ts index f15aa9ffb..4837ba4f4 100644 --- a/browser_tests/globalSetupWithI18n.ts +++ b/browser_tests/globalSetupWithI18n.ts @@ -8,16 +8,16 @@ import { preprocessLitegraph } from './i18nSetup' export default async function globalSetupWithI18n() { // First preprocess litegraph files await preprocessLitegraph() - + // Then run regular global setup await globalSetup() - + // Register cleanup handlers const cleanup = async () => { const { restoreLitegraph } = await import('./i18nSetup') await restoreLitegraph() } - + process.on('exit', cleanup) process.on('SIGINT', async () => { await cleanup() @@ -27,4 +27,4 @@ export default async function globalSetupWithI18n() { await cleanup() process.exit(0) }) -} \ No newline at end of file +} diff --git a/browser_tests/globalTeardownWithI18n.ts b/browser_tests/globalTeardownWithI18n.ts index 289970779..22e29711d 100644 --- a/browser_tests/globalTeardownWithI18n.ts +++ b/browser_tests/globalTeardownWithI18n.ts @@ -8,7 +8,7 @@ import { restoreLitegraph } from './i18nSetup' export default async function globalTeardownWithI18n() { // First run regular teardown await globalTeardown() - + // Then restore litegraph files await restoreLitegraph() -} \ No newline at end of file +} diff --git a/browser_tests/i18nSetup.ts b/browser_tests/i18nSetup.ts index bdaab9877..10b374b93 100644 --- a/browser_tests/i18nSetup.ts +++ b/browser_tests/i18nSetup.ts @@ -3,9 +3,9 @@ * Handles preprocessing of litegraph files that contain TypeScript 'declare' keywords */ import { promises as fs } from 'fs' +import { glob } from 'glob' import * as path from 'path' import { fileURLToPath } from 'url' -import { glob } from 'glob' const __dirname = path.dirname(fileURLToPath(import.meta.url)) const rootDir = path.resolve(__dirname, '..') @@ -22,7 +22,7 @@ async function findFilesWithDeclare(): Promise { const files = await glob(pattern, { ignore: ['**/*.test.ts', '**/*.spec.ts', '**/node_modules/**'] }) - + // Filter to only files that actually contain 'declare' keyword const filesWithDeclare = await Promise.all( files.map(async (filePath) => { @@ -36,35 +36,35 @@ async function findFilesWithDeclare(): Promise { } }) ) - + return filesWithDeclare.filter((file): file is string => file !== null) } export async function preprocessLitegraph() { console.log('Preprocessing litegraph files for i18n collection...') - + const filesToProcess = await findFilesWithDeclare() - + if (filesToProcess.length === 0) { console.log(' ℹ No files with declare keywords found') return } - + console.log(` Found ${filesToProcess.length} files with declare keywords`) - + await Promise.all( filesToProcess.map(async (filePath) => { const originalContent = await fs.readFile(filePath, 'utf-8') - + // Store original content in memory backupMap.set(filePath, originalContent) - + // Remove 'declare' keyword from class properties const modifiedContent = originalContent.replace( /^(\s*)declare\s+/gm, '$1// @ts-ignore - removed declare for Playwright\n$1' ) - + // Write modified content await fs.writeFile(filePath, modifiedContent) console.log(` ✓ Processed ${path.relative(litegraphSrcDir, filePath)}`) @@ -76,15 +76,15 @@ export async function restoreLitegraph() { if (backupMap.size === 0) { return } - + console.log('Restoring original litegraph files...') - + await Promise.all( Array.from(backupMap.entries()).map(async ([filePath, originalContent]) => { await fs.writeFile(filePath, originalContent) console.log(` ✓ Restored ${path.relative(litegraphSrcDir, filePath)}`) }) ) - + backupMap.clear() -} \ No newline at end of file +}