Skip to content

Commit

Permalink
🐛 Fix linting and exclude
Browse files Browse the repository at this point in the history
  • Loading branch information
BetaHuhn committed Jan 7, 2023
1 parent 6f1bf85 commit d2b8086
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
File renamed without changes.
51 changes: 26 additions & 25 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,34 +79,35 @@ export async function write(src, dest, context) {

export async function copy(src, dest, isDirectory, file) {
const deleteOrphaned = isDirectory && file.deleteOrphaned
const exclude = file.exclude

const filterFunc = (file) => {

if (exclude !== undefined) {

// Check if file-path is one of the present filepaths in the excluded paths
// This has presedence over the single file, and therefore returns before the single file check
let filePath = ''
if (file.endsWith('/')) {
//File item is a folder
filePath = file
} else {
//File item is a file
filePath = file.split('\/').slice(0,-1).join('/')+'/'
}
if (exclude.includes(filePath)) {
core.debug(`Excluding file ${ file } since its path is included as one of the excluded paths.`)
return false
}
//Or if the file itself is in the excluded files
if (exclude.includes(file)) {
core.debug(`Excluding file ${ file } since it is explicitly added in the exclusion list.`)
return false
}
}
if (exclude !== undefined) {

// Check if file-path is one of the present filepaths in the excluded paths
// This has presedence over the single file, and therefore returns before the single file check
let filePath = ''
if (file.endsWith('/')) {
// File item is a folder
filePath = file
} else {
// File item is a file
filePath = file.split('\/').slice(0, -1).join('/') + '/'
}

if (exclude.includes(filePath)) {
core.debug(`Excluding file ${ file } since its path is included as one of the excluded paths.`)
return false
}


// Or if the file itself is in the excluded files
if (exclude.includes(file)) {
core.debug(`Excluding file ${ file } since it is explicitly added in the exclusion list.`)
return false
}
}
return true
}

Expand Down

0 comments on commit d2b8086

Please sign in to comment.