Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a
flat
commands that sad bye if π² π
ββοΈ flat
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import {EOL} from "os" | ||
import {handler as depcountHandler} from "./depcount" | ||
import * as symbols from "../symbols" | ||
|
||
export let command = "flat" | ||
export let describe = "exit badly if the tree cannot be flat" | ||
|
||
export let builder = yargs => { | ||
yargs | ||
.options("origami", { | ||
type: "boolean" | ||
}) | ||
.options("pattern", { | ||
alias: ["r"], | ||
type: "array", | ||
describe: "only count packages whose name match one of these patterns", | ||
coerce: pattern => new RegExp(pattern) | ||
}) | ||
.options("production", { | ||
alias: ["prod", "p"], | ||
type: "boolean", | ||
default: "false", | ||
describe: "only count the production (non-dev) tree" | ||
}) | ||
} | ||
|
||
export async function handler (argv) { | ||
let options = argv.origami | ||
? { | ||
production: true, | ||
pattern: /@financial-times\/o-.*/ | ||
} | ||
: argv | ||
|
||
let counts = await depcountHandler({ | ||
...options, | ||
min: 2, | ||
[symbols.internal]: true | ||
}) | ||
|
||
process.exit(counts.length) | ||
} |