(projectRoot)
| 59 | } |
| 60 | |
| 61 | function changedFilesFromGit(projectRoot) { |
| 62 | const dirty = [ |
| 63 | ...splitLines(runGit(projectRoot, ['diff', '--name-only'])), |
| 64 | ...splitLines(runGit(projectRoot, ['diff', '--name-only', '--cached'])), |
| 65 | ...splitLines(runGit(projectRoot, ['status', '--short'])) |
| 66 | .filter((line) => line.startsWith('?? ')) |
| 67 | .flatMap((line) => listUntrackedPath(projectRoot, line.slice(3).trim())), |
| 68 | ]; |
| 69 | if (dirty.length > 0) return unique(dirty.map(normalizePath)); |
| 70 | |
| 71 | const headRange = splitLines(runGit(projectRoot, ['diff', '--name-only', 'HEAD~1', 'HEAD'])); |
| 72 | if (headRange.length > 0) return unique(headRange.map(normalizePath)); |
| 73 | |
| 74 | return splitLines(runGit(projectRoot, ['ls-files'])).map(normalizePath); |
| 75 | } |
| 76 | |
| 77 | function defaultCommand(scripts) { |
| 78 | if (scripts.test) return 'npm run test'; |
no test coverage detected