fix(verify-runner): ESM 兼容 checkDeps playwright 检测 (Phase 3 接入发现)
Phase 3 接入 _browser_verify 后跑 form create --verify=warn, checkDeps
返 playwright=false. 原代码用 require.resolve('playwright', { paths: [...] })
在 ESM (tsx) 上下文里 require 未定义, require.resolve 抛错被 catch 吞掉.
改用 fs.existsSync 探测 /dacli/node_modules/playwright/package.json.
简单, 跨 CJS/ESM 都工作.
Co-Authored-By: Claude <[email protected]>
This commit is contained in:
1 parent
341f48ef75
commit
85039be6f8
1 file changed
+8
-4
@@ -12,7 +12,7 @@
|
||||
* Spec: docs/superpowers/specs/2026-06-16-dacli-form-browser-verify-design.md
|
||||
*/
|
||||
import { spawn } from 'node:child_process'
|
||||
import { existsSync, mkdirSync, copyFileSync, readdirSync } from 'node:fs'
|
||||
import { existsSync, mkdirSync, copyFileSync, readdirSync, statSync } from 'node:fs'
|
||||
import { join } from 'node:path'
|
||||
import { currentBaseUrl } from './config.ts'
|
||||
|
||||
@@ -51,11 +51,15 @@ let _depsCache: Deps | null = null
|
||||
export async function checkDeps(): Promise<Deps> {
|
||||
if (_depsCache) return _depsCache
|
||||
|
||||
// 1. playwright 包
|
||||
// 1. playwright 包 — ESM 兼容 (CJS require.resolve 在 ESM 不可用, 走 fs.existsSync)
|
||||
let playwright = false
|
||||
try {
|
||||
require.resolve('playwright', { paths: [join(WORK_DIR, 'dacli')] })
|
||||
playwright = true
|
||||
const pwPath = join(WORK_DIR, 'dacli', 'node_modules', 'playwright', 'package.json')
|
||||
if (existsSync(pwPath)) {
|
||||
// sanity check: package.json 是个真文件不是空目录
|
||||
statSync(pwPath)
|
||||
playwright = true
|
||||
}
|
||||
} catch {}
|
||||
|
||||
// 2. chromium 二进制
|
||||
|
||||
Reference in new issue
Block a user