/
get-filtered-packages.js
40 lines (31 loc) · 1.08 KB
/
get-filtered-packages.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"use strict";
const collectUpdates = require("@lerna/collect-updates");
const filterPackages = require("@lerna/filter-packages");
module.exports = getFilteredPackages;
function getFilteredPackages(packageGraph, execOpts, options) {
let chain = Promise.resolve();
chain = chain.then(() =>
filterPackages(
packageGraph.rawPackageList,
options.scope,
options.ignore,
options.private,
options.continueIfNoMatch
)
);
if (options.since !== undefined) {
chain = chain.then(filteredPackages =>
Promise.resolve(collectUpdates(filteredPackages, packageGraph, execOpts, options)).then(updates => {
const updated = new Set(updates.map(({ pkg }) => pkg.name));
return filteredPackages.filter(pkg => updated.has(pkg.name));
})
);
}
if (options.includeFilteredDependents) {
chain = chain.then(filteredPackages => packageGraph.addDependents(filteredPackages));
}
if (options.includeFilteredDependencies) {
chain = chain.then(filteredPackages => packageGraph.addDependencies(filteredPackages));
}
return chain;
}