MCPcopy
hub / github.com/xpf0000/FlyEnv / next

Function next

scripts/dev-runner.ts:152–178  ·  view source on GitHub ↗
(base: string, file?: string | null)

Source from the content-addressed store, hash-verified

150let preveMd5 = ''
151let fsWait = false
152const next = (base: string, file?: string | null) => {
153 if (file) {
154 if (fsWait) return
155 const fullPath = _path.join(base, file)
156 try {
157 if (!_fs.statSync(fullPath).isFile()) return
158 } catch {
159 return
160 }
161 const currentMd5 = _md5(_fs.readFileSync(fullPath)) as string
162 if (currentMd5 == preveMd5) {
163 return
164 }
165 fsWait = true
166 preveMd5 = currentMd5
167 console.log(`${file} file has been updated`)
168 restart = true
169 buildMainProcess()
170 .then()
171 .catch((err) => {
172 console.error(err)
173 })
174 setTimeout(() => {
175 fsWait = false
176 }, 500)
177 }
178}
179const mainPath = _path.resolve(__dirname, '../src/main/')
180_fs.watch(
181 mainPath,

Callers 3

runMethod · 0.85
_handleMethod · 0.85
dev-runner.tsFile · 0.85

Calls 5

buildMainProcessFunction · 0.85
catchMethod · 0.80
logMethod · 0.45
thenMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected