mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 06:20:11 +00:00
fix: use path.basename for cross-platform path inference in transform
Addresses review feedback: https://github.com/Comfy-Org/ComfyUI_frontend/pull/10694#discussion_r3005550584
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { readFileSync, writeFileSync } from 'node:fs'
|
||||
import { basename } from 'node:path'
|
||||
import pc from 'picocolors'
|
||||
import { transform, formatTransformSummary } from '../transform/engine'
|
||||
import { header } from '../ui/logger'
|
||||
@@ -26,10 +27,8 @@ export async function runTransform(
|
||||
console.log()
|
||||
|
||||
// Transform
|
||||
const testName =
|
||||
options.testName ??
|
||||
filePath.split('/').pop()?.replace('.raw.spec.ts', '') ??
|
||||
'test'
|
||||
const inferredName = basename(filePath).replace(/\.raw\.spec\.ts$/, '')
|
||||
const testName = options.testName ?? (inferredName || 'test')
|
||||
const tags = options.tags ?? ['@canvas']
|
||||
const result = transform(rawCode, { testName, tags })
|
||||
|
||||
@@ -42,7 +41,15 @@ export async function runTransform(
|
||||
|
||||
// Write output
|
||||
const outputPath =
|
||||
options.output ?? filePath.replace('.raw.spec.ts', '.spec.ts')
|
||||
options.output ?? filePath.replace(/\.raw\.spec\.ts$/, '.spec.ts')
|
||||
if (!options.output && outputPath === filePath) {
|
||||
console.log(
|
||||
pc.red(
|
||||
' Refusing to overwrite input file. Pass --output or use a *.raw.spec.ts input.'
|
||||
)
|
||||
)
|
||||
process.exit(1)
|
||||
}
|
||||
writeFileSync(outputPath, result.code)
|
||||
console.log(pc.green(` ✅ Saved: ${outputPath}`))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user