Skip to content

Commit ee1753b

Browse files
committed
Added support to ignore/include a pattern of files
- We can control which files from a directory should be ignored or included by using a regex pattern. - This is useful for cases where we want to ignore certain files (e.g., temporary files, logs) or include specific files (e.g., configuration files) based on their names or extensions.
1 parent 80cbf1f commit ee1753b

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ const parseFiles = (files) => {
195195
template: item.template === undefined ? TEMPLATE_DEFAULT : item.template,
196196
replace: item.replace === undefined ? REPLACE_DEFAULT : item.replace,
197197
deleteOrphaned: item.deleteOrphaned === undefined ? DELETE_ORPHANED_DEFAULT : item.deleteOrphaned,
198+
excludeFilePatterns: item.excludeFilePatterns === undefined ? [] : item.excludeFilePatterns,
199+
includeFilePatterns: item.includeFilePatterns === undefined ? [] : item.includeFilePatterns,
198200
exclude: parseExclude(item.exclude, item.source)
199201
}
200202
}

src/helpers.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,32 @@ export async function copy(src, dest, isDirectory, file) {
126126
return false
127127
}
128128
}
129+
130+
// Check if the file matches any of the excludeFilePatterns
131+
if (file.excludeFilePatterns.length > 0) {
132+
for (const pattern of file.excludeFilePatterns) {
133+
if (srcFile.match(pattern)) {
134+
core.debug(`Excluding file ${ srcFile } since it matches the excludeFilePattern ${ pattern }.`)
135+
return false
136+
}
137+
}
138+
}
139+
140+
// Check if the file matches any of the includeFilePatterns
141+
if (file.includeFilePatterns.length > 0) {
142+
let matches = false
143+
for (const pattern of file.includeFilePatterns) {
144+
if (srcFile.match(pattern)) {
145+
matches = true
146+
break
147+
}
148+
}
149+
150+
if (!matches) {
151+
core.debug(`Excluding file ${ srcFile } since it does not match any of the includeFilePatterns.`)
152+
return false
153+
}
154+
}
129155
return true
130156
}
131157

0 commit comments

Comments
 (0)