-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathgenerate-path-matrix.js
More file actions
65 lines (62 loc) · 1.95 KB
/
generate-path-matrix.js
File metadata and controls
65 lines (62 loc) · 1.95 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import {
require_micromatch
} from "../main-v9jqraeg.js";
import {
getChangedFilepaths
} from "../main-mycz0558.js";
import {
require_lodash
} from "../main-pet5htdh.js";
import {
HelperInputs
} from "../main-8h70j5cy.js";
import"../main-4c5nddsb.js";
import {
context
} from "../main-6avxv4a6.js";
import"../main-9m3k9gt0.js";
import {
error
} from "../main-q70tmm6g.js";
import {
__toESM
} from "../main-wckvcay0.js";
// src/helpers/generate-path-matrix.ts
var import_lodash = __toESM(require_lodash(), 1);
var import_micromatch = __toESM(require_micromatch(), 1);
class GeneratePathMatrix extends HelperInputs {
}
var generatePathMatrix = async ({
paths,
globs,
override_filter_paths,
override_filter_globs,
paths_no_filter,
batches
}) => {
const pathsToUse = paths || globs;
if (!pathsToUse) {
error("Must supply one of paths, globs");
throw new Error;
}
const changedFiles = await getChangedFilepaths(context.issue.number);
const shouldOverrideFilter = override_filter_globs ? import_micromatch.default(changedFiles, override_filter_globs.split(`
`)).length > 0 : changedFiles.some((changedFile) => override_filter_paths?.split(/[\n,]/).includes(changedFile));
const splitPaths = pathsToUse.split(/[\n,]/);
const basePaths = shouldOverrideFilter ? splitPaths : paths ? splitPaths.filter((path) => changedFiles.some((changedFile) => changedFile.startsWith(path))) : splitPaths.filter((glob) => import_micromatch.default(changedFiles, glob).length > 0);
const extraPaths = paths_no_filter?.split(/[\n,]/) ?? [];
const matrixValues = import_lodash.uniq(basePaths.concat(extraPaths));
if (batches) {
return {
include: import_lodash.chunk(matrixValues, Math.ceil(matrixValues.length / Number(batches))).map((chunk2) => ({ path: chunk2.join(",") }))
};
}
return {
include: matrixValues.map((path) => ({ path }))
};
};
export {
generatePathMatrix,
GeneratePathMatrix
};
//# debugId=5F012EC0CB77383764756E2164756E21