-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathbuild-ignore.js
70 lines (66 loc) · 3.59 KB
/
build-ignore.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { exec } = require('node:child_process');
console.log('Checking if the site needs to build...');
const COMMIT = process.env.COMMIT_REF;
let gitDiff = '';
switch (process.env.VITE_SITE_NAME) {
case 'system':
console.log('site match found, checking diff for changes');
gitDiff = `git diff main ${COMMIT} -- ./packages/system/`;
break;
case 'landing':
console.log('landing site match found, checking diff for changes');
gitDiff = `git diff main ${COMMIT} -- ./packages/system/ ./packages/landing-site/`;
break;
case 'react':
console.log('react site match found, checking diff for changes');
gitDiff = `git diff main ${COMMIT} -- ./packages/system/ ./packages/site/src/content/react-*/ ./packages/site/src/components/ ./packages/site/src/layouts/ ./packages/site/src/pages/ ./packages/site/*.*`;
break;
case 'nodejs':
console.log('node site match found, checking diff for changes');
gitDiff = `git diff main ${COMMIT} -- ./packages/system/ ./packages/site/src/content/nodejs-*/ ./packages/site/src/components/ ./packages/site/src/layouts/ ./packages/site/src/pages/ ./packages/site/*.*`;
break;
case 'graphql':
console.log('graphql site match found, checking diff for changes');
gitDiff = `git diff main ${COMMIT} -- ./packages/system/ ./packages/site/src/content/graphql-*/ ./packages/site/src/components/ ./packages/site/src/layouts/ ./packages/site/src/pages/ ./packages/site/*.*`;
break;
case 'vue':
console.log('vue site match found, checking diff for changes');
gitDiff = `git diff main ${COMMIT} -- ./packages/system/ ./packages/site/src/content/vue-*/ ./packages/site/src/components/ ./packages/site/src/layouts/ ./packages/site/src/pages/ ./packages/site/*.*`;
break;
case 'angular':
console.log('angular site match found, checking diff for changes');
gitDiff = `git diff main ${COMMIT} -- ./packages/system/ ./packages/site/src/content/angular-*/ ./packages/site/src/components/ ./packages/site/src/layouts/ ./packages/site/src/pages/ ./packages/site/*.*`;
break;
case 'svelte':
console.log('svelte site match found, checking diff for changes');
gitDiff = `git diff main ${COMMIT} -- ./packages/system/ ./packages/site/src/content/svelte-*/ ./packages/site/src/components/ ./packages/site/src/layouts/ ./packages/site/src/pages/ ./packages/site/*.*`;
break;
case 'solidjs':
console.log('solid site match found, checking diff for changes');
gitDiff = `git diff main ${COMMIT} -- ./packages/system/ ./packages/site/src/content/solidjs-*/ ./packages/site/src/components/ ./packages/site/src/layouts/ ./packages/site/src/pages/ ./packages/site/*.*`;
break;
case 'qwik':
console.log('qwik site match found, checking diff for changes');
gitDiff = `git diff main ${COMMIT} -- ./packages/system/ ./packages/site/src/content/qwik-*/ ./packages/site/src/components/ ./packages/site/src/layouts/ ./packages/site/src/pages/ ./packages/site/*.*`;
break;
case 'deno':
console.log('deno site match found, checking diff for changes');
gitDiff = `git diff main ${COMMIT} -- ./packages/system/ ./packages/site/src/content/deno-*/ ./packages/site/src/components/ ./packages/site/src/layouts/ ./packages/site/src/pages/ ./packages/site/*.*`;
break;
default:
console.log('no matches, exiting build process');
return (process.exitCode = 0);
}
exec(gitDiff, (error, stdout) => {
if (error) {
console.error(`exec error: ${error}`);
return error.code;
}
console.log(
stdout
? 'changes found, starting build'
: 'no changes found, no build needed',
);
return stdout ? (process.exitCode = 1) : (process.exitCode = 0);
});