From 29600fd9d204bc329fcd535c906fa054718850af Mon Sep 17 00:00:00 2001 From: chee Date: Sun, 17 Feb 2019 20:47:48 +0000 Subject: [PATCH] add a command for showing what directly requires a given package --- commands/requires.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 commands/requires.js diff --git a/commands/requires.js b/commands/requires.js new file mode 100644 index 0000000..6f8de4a --- /dev/null +++ b/commands/requires.js @@ -0,0 +1,23 @@ +import getLockfile from "../functions/get-lockfile" +import findDependents from "../functions/recursors/find-dependents" + +export let command = "requires " +export let describe = "see what packages directly need a given package" +export let aliases = [ + "who-needs", + "whoneeds" +] +export let builder = yargs => + yargs + .positional("name", { + describe: "the package name", + required: true + }) + +export async function handler (argv) { + let lockfile = await getLockfile(argv) + + let requires = await findDependents(argv.name)(lockfile.dependencies) + + console.log(requires.join(" ")) +}