bhg-helper 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { Router } from 'express'
5
5
  import { spawn, type ChildProcess } from 'node:child_process'
6
- import { existsSync, statSync } from 'node:fs'
6
+ import { existsSync } from 'node:fs'
7
7
  import { resolve, dirname } from 'node:path'
8
8
  import { fileURLToPath } from 'node:url'
9
9
  import { log } from '../lib/logger.js'
@@ -19,8 +19,8 @@ const PACKAGE_JSON = resolve(PROJECT_ROOT, 'package.json')
19
19
 
20
20
  // 单实例:同一时间只允许一个 npm install
21
21
  let running: ChildProcess | null = null
22
- let logBuffer: { ts: number; line: string }[] = []
23
- let sseClients: Set<import('express').Response> = new Set()
22
+ const logBuffer: { ts: number; line: string }[] = []
23
+ const sseClients: Set<import('express').Response> = new Set()
24
24
 
25
25
  function pushLog(line: string) {
26
26
  if (!line) return
@@ -65,10 +65,8 @@ router.get('/status', async (_req, res) => {
65
65
  const hasPackageJson = existsSync(PACKAGE_JSON)
66
66
  // 检查 node_modules 是否真的完整安装(有 react 包确认不是空壳)
67
67
  const hasReact = hasNodeModules && existsSync(resolve(NODE_MODULES, 'react'))
68
- const nodeModMtime = hasNodeModules ? statSync(NODE_MODULES).mtimeMs : 0
69
- const pkgMtime = hasPackageJson ? statSync(PACKAGE_JSON).mtimeMs : 0
70
- // 需要安装的条件:node_modules 不存在、关键包缺失、或 package.json 更新时间晚于 node_modules
71
- const needsInstall = !hasNodeModules || !hasReact || (pkgMtime > nodeModMtime)
68
+ // 只需要 node_modules 存在且有 react 包就算装好了
69
+ const needsInstall = !hasNodeModules || !hasReact
72
70
 
73
71
  const node = await checkNode()
74
72
  const npm = await checkNpm()