This repository has been archived by the owner on Oct 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilematcher.js
52 lines (47 loc) · 1.51 KB
/
filematcher.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
41
42
43
44
45
46
47
48
49
50
51
52
function filematcher(filenames) {
const sharedFrontendFiles = [
'.nvmrc',
'.npmrc',
'package.json',
'package-lock.json',
];
const matchesAdminFrontend = ['frontend/admin/'];
const matchesWebclientFrontend = ['frontend/webclient/'];
const matchesImportFrontend = ['frontend/importer/'];
const pythonWillRunForAllButThese = [
...sharedFrontendFiles,
...matchesAdminFrontend,
...matchesWebclientFrontend,
...matchesImportFrontend,
];
matchesAdminFrontend.push(...sharedFrontendFiles);
matchesWebclientFrontend.push(...sharedFrontendFiles);
matchesImportFrontend.push('.nvmrc');
const run_python = !!filenames.find((file) => {
return pythonWillRunForAllButThese.every((match) => {
return !file.startsWith(match);
});
});
const run_admin = !!filenames.find((file) => {
return matchesAdminFrontend.find((match) => {
return file.startsWith(match);
});
});
const run_webclient = !!filenames.find((file) => {
return matchesWebclientFrontend.find((match) => {
return file.startsWith(match);
});
});
const run_importer = !!filenames.find((file) => {
return matchesImportFrontend.find((match) => {
return file.startsWith(match);
});
});
return {
python: run_python,
admin: run_admin,
webclient: run_webclient,
importer: run_importer,
};
}
module.exports = filematcher;