(dir: string)
| 22 | const results: string[] = []; |
| 23 | |
| 24 | function walk(dir: string) { |
| 25 | let entries: string[] = []; |
| 26 | try { |
| 27 | entries = readdirSync(dir); |
| 28 | } catch { |
| 29 | return; |
| 30 | } |
| 31 | for (const name of entries) { |
| 32 | if (name === 'node_modules' || name === '.ns-vite-build' || name === 'dist') continue; |
| 33 | const full = path.join(dir, name); |
| 34 | let st: any; |
| 35 | try { |
| 36 | st = statSync(full); |
| 37 | } catch { |
| 38 | continue; |
| 39 | } |
| 40 | if (st.isDirectory()) { |
| 41 | walk(full); |
| 42 | } else if (st.isFile() && (name.endsWith('.ts') || name.endsWith('.js'))) { |
| 43 | try { |
| 44 | const code = readFileSync(full, 'utf8'); |
| 45 | // Heuristic: treat files that bootstrap Angular (platformNativeScript, bootstrapApplication, etc.) |
| 46 | // as HMR-relevant roots. |
| 47 | if (/bootstrapApplication\s*\(|platformNativeScript/i.test(code) || /@NgModule\s*\(/.test(code)) { |
| 48 | const rel = '/' + path.relative(root, full).split(path.sep).join('/'); |
| 49 | results.push(rel); |
| 50 | } |
| 51 | } catch {} |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | walk(srcDir); |
| 57 | return results; |
no test coverage detected