forked from web-infra-dev/rsbuild
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathskipCI.js
41 lines (35 loc) · 902 Bytes
/
skipCI.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
const { execSync } = require('child_process');
const SKIP_FOLDERS = [
'cspell.json',
'.changeset',
'.github',
'.vscode',
'packages/document',
'scripts/skipCI.js',
];
async function main() {
execSync('git fetch origin main');
const changedFilesOutput = execSync('git diff origin/main... --name-only', {
stdio: 'pipe',
}).toString();
const changedFiles = changedFilesOutput
.split('\n')
.map((file) => file && file.trim())
.filter(Boolean);
const shouldNotSkipCI =
!changedFiles.length ||
changedFiles.some(
(file) =>
!SKIP_FOLDERS.some(
(folder) =>
file.startsWith(`${folder}/`) ||
file === folder ||
file.endsWith('.md'),
),
);
console.log(shouldNotSkipCI ? 'false' : 'true');
}
main().catch((err) => {
console.error('Failed to detect CI skip', err);
process.exit(1);
});