mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-03 22:59:14 +00:00
style: Apply Prettier formatting
- Fix trailing whitespace - Add missing newlines at end of files
This commit is contained in:
@@ -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)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<string[]> {
|
||||
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<string[]> {
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user