Add source diff for CI

This commit is contained in:
the1812 2021-12-13 22:12:42 +08:00
parent 02294d7761
commit 9ecec7e290

29
webpack/source-diff.js Normal file
View File

@ -0,0 +1,29 @@
const process = require('child_process')
const excludePatterns = [
/^docs?\//,
/^\.vscode\//,
/^\.git/,
/^builder\//,
/^images\//,
/^min\//,
/^README\.md$/,
/^CHANGELOG\.md$/,
/^CODE_OF_CONDUCT\.md$/,
/^LICENCE$/,
]
const isSourceChanged = () => {
const lastDiff = process
.execSync('git diff --name-only HEAD^')
.toString()
.trim()
.split('\n')
const isAllExcluded = lastDiff.every(path => excludePatterns.some(p => p.test(path)))
return !isAllExcluded
}
module.exports = {
isSourceChanged,
}