From 26b65790df33e3c981827ea75c5a0570c3255396 Mon Sep 17 00:00:00 2001 From: chee Date: Thu, 21 Feb 2019 01:41:04 +0000 Subject: [PATCH] =?UTF-8?q?Add=20a=20`flat`=20commands=20that=20sad=20bye?= =?UTF-8?q?=20if=20=F0=9F=8C=B2=20=F0=9F=99=85=E2=80=8D=E2=99=80=EF=B8=8F?= =?UTF-8?q?=20flat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/flat.js | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 commands/flat.js diff --git a/commands/flat.js b/commands/flat.js new file mode 100644 index 0000000..6d586f7 --- /dev/null +++ b/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) +}