Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit de5bb4e

Browse files
authored
gather to accept optional files (#20)
* gather to accept optional files * bump version
1 parent 9a32f90 commit de5bb4e

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@canva/dependency-tree",
3-
"version": "3.1.6",
3+
"version": "3.1.7",
44
"description": "Calculates a dependency tree for set of files",
55
"main": "dist/index.js",
66
"author": "Canva Pty Ltd",

src/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,11 @@ export class DependencyTree {
157157
* Built-in (Node) and package dependencies are ignored.
158158
*/
159159
public async gather({
160+
// The files to gather dependencies for
161+
// by default globbing is used to find files from rootDirs
162+
filesToProcess,
160163
batchSize = 10,
161-
}: { batchSize?: number } = {}): Promise<{
164+
}: { batchSize?: number; filesToProcess?: readonly string[] } = {}): Promise<{
162165
missing: FileToDeps;
163166
resolved: FileToDeps;
164167
}> {
@@ -170,7 +173,7 @@ export class DependencyTree {
170173

171174
const fileToDeps: FileToDeps = new Map();
172175
const missing: FileToDeps = new Map();
173-
const files = this.getFiles();
176+
const files = filesToProcess ?? this.getFiles();
174177
info(`Found a total of ${files.length} source files`);
175178

176179
const getDepsForFilesTasks = files.map((file: string) => async () => {

0 commit comments

Comments
 (0)