| 62 | } |
| 63 | |
| 64 | function hasCSSModules(dir: string, depth = 0): boolean { |
| 65 | if (depth > 4) return false; |
| 66 | try { |
| 67 | const entries = fs.readdirSync(dir, { withFileTypes: true }); |
| 68 | for (const entry of entries) { |
| 69 | if (entry.name === 'node_modules' || entry.name === '.git') continue; |
| 70 | if (entry.isFile() && /\.module\.(css|scss|less)$/.test(entry.name)) { |
| 71 | return true; |
| 72 | } |
| 73 | if (entry.isDirectory() && depth < 4) { |
| 74 | if (hasCSSModules(path.join(dir, entry.name), depth + 1)) return true; |
| 75 | } |
| 76 | } |
| 77 | } catch { |
| 78 | // Permission errors etc. |
| 79 | } |
| 80 | return false; |
| 81 | } |
| 82 | |
| 83 | export function getProjectName(projectDir: string, overrideName?: string): string { |
| 84 | if (overrideName) return overrideName; |