(currentDir)
| 8 | } |
| 9 | |
| 10 | export function getProjectRoot(currentDir) { |
| 11 | let dir = currentDir |
| 12 | while (dir !== path.parse(dir).root) { |
| 13 | if (fs.existsSync(path.join(dir, 'package.json'))) { |
| 14 | return dir |
| 15 | } |
| 16 | dir = path.dirname(dir) |
| 17 | } |
| 18 | throw new Error('找不到项目根目录 (未找到 package.json)') |
| 19 | } |
| 20 | |
| 21 | export function log(level, ...args) { |
| 22 | console.log(`[${level}]`, ...args) |
no outgoing calls
no test coverage detected