Skip to content

Commit

Permalink
Add a flat commands that sad bye if 🌲 πŸ™…β€β™€οΈ flat
Browse files Browse the repository at this point in the history
  • Loading branch information
chee committed Feb 21, 2019
1 parent ef77547 commit 26b6579
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions commands/flat.js
@@ -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)
}

0 comments on commit 26b6579

Please sign in to comment.