(args)
| 42 | #filterSet |
| 43 | |
| 44 | async exec (args) { |
| 45 | const Arborist = require('@npmcli/arborist') |
| 46 | const arb = new Arborist({ |
| 47 | ...this.npm.flatOptions, |
| 48 | path: this.npm.global ? resolve(this.npm.globalDir, '..') : this.npm.prefix, |
| 49 | }) |
| 50 | this.#tree = await arb.loadActual() |
| 51 | |
| 52 | if (this.workspaceNames?.length) { |
| 53 | this.#filterSet = arb.workspaceDependencySet( |
| 54 | this.#tree, |
| 55 | this.workspaceNames, |
| 56 | this.npm.flatOptions.includeWorkspaceRoot |
| 57 | ) |
| 58 | } else if (!this.npm.flatOptions.workspacesEnabled) { |
| 59 | this.#filterSet = arb.excludeWorkspacesDependencySet(this.#tree) |
| 60 | } |
| 61 | |
| 62 | if (args.length) { |
| 63 | for (const arg of args) { |
| 64 | // specific deps |
| 65 | this.#getEdges(this.#tree.inventory.query('name', arg), 'edgesIn') |
| 66 | } |
| 67 | } else { |
| 68 | if (this.npm.config.get('all')) { |
| 69 | // all deps in tree |
| 70 | this.#getEdges(this.#tree.inventory.values(), 'edgesOut') |
| 71 | } |
| 72 | // top-level deps |
| 73 | this.#getEdges() |
| 74 | } |
| 75 | |
| 76 | await Promise.all([...this.#edges].map((e) => this.#getOutdatedInfo(e))) |
| 77 | |
| 78 | // sorts list alphabetically by name and then dependent |
| 79 | const outdated = this.#list |
| 80 | .sort((a, b) => localeCompare(a.name, b.name) || localeCompare(a.dependent, b.dependent)) |
| 81 | |
| 82 | if (outdated.length) { |
| 83 | process.exitCode = 1 |
| 84 | } |
| 85 | |
| 86 | if (this.npm.config.get('json')) { |
| 87 | output.buffer(this.#json(outdated)) |
| 88 | return |
| 89 | } |
| 90 | |
| 91 | const res = this.npm.config.get('parseable') |
| 92 | ? this.#parseable(outdated) |
| 93 | : this.#pretty(outdated) |
| 94 | |
| 95 | if (res) { |
| 96 | output.standard(res) |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | #getEdges (nodes, type) { |
| 101 | // when no nodes are provided then it should only read direct deps from the root node and its workspaces direct dependencies |
nothing calls this directly
no test coverage detected