| 13 | // next dependency in package.json. |
| 14 | // --------------------------------------------- |
| 15 | export function isNextProject(cwd: string = process.cwd()): boolean { |
| 16 | if (existsSync(path.join(cwd, 'next.config.js'))) return true; |
| 17 | try { |
| 18 | const pkg = JSON.parse( |
| 19 | readFileSync(path.join(cwd, 'package.json'), 'utf8') |
| 20 | ); |
| 21 | return ( |
| 22 | pkg.dependencies?.next !== undefined || |
| 23 | pkg.devDependencies?.next !== undefined |
| 24 | ); |
| 25 | } catch { |
| 26 | return false; |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | // --------------------------------------------- |
| 31 | // Detect if the current directory is a React |