cli: add --since flag for repo lint command
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -51,6 +51,10 @@ export function registerRepoCommand(program: CommanderStatic) {
|
||||
'Lint report output format',
|
||||
'eslint-formatter-friendly',
|
||||
)
|
||||
.option(
|
||||
'--since <ref>',
|
||||
'Only lint packages that changed since the specified ref',
|
||||
)
|
||||
.option('--fix', 'Attempt to automatically fix violations')
|
||||
.action(lazy(() => import('./repo/lint').then(m => m.command)));
|
||||
}
|
||||
|
||||
@@ -22,7 +22,12 @@ import { runWorkerQueueThreads } from '../../lib/parallel';
|
||||
import { paths } from '../../lib/paths';
|
||||
|
||||
export async function command(cmd: Command): Promise<void> {
|
||||
const packages = await PackageGraph.listTargetPackages();
|
||||
let packages = await PackageGraph.listTargetPackages();
|
||||
|
||||
if (cmd.since) {
|
||||
const graph = PackageGraph.fromPackages(packages);
|
||||
packages = await graph.listChangedPackages({ ref: cmd.since });
|
||||
}
|
||||
|
||||
// This formatter uses the cwd to format file paths, so let's have that happen from the root instead
|
||||
if (cmd.format === 'eslint-formatter-friendly') {
|
||||
|
||||
Reference in New Issue
Block a user