(base: string, file?: string | null)
| 150 | let preveMd5 = '' |
| 151 | let fsWait = false |
| 152 | const 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 | } |
| 179 | const mainPath = _path.resolve(__dirname, '../src/main/') |
| 180 | _fs.watch( |
| 181 | mainPath, |
no test coverage detected