Skip to content

Commit

Permalink
🐛 Do not delete excluded files if deleteOrphaned is true (#98)
Browse files Browse the repository at this point in the history
Fixes #97
  • Loading branch information
Nef10 authored Sep 6, 2021
1 parent 893f849 commit 013b028
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const fs = require('fs-extra')
const readfiles = require('node-readfiles')
const { exec } = require('child_process')
const core = require('@actions/core')
const path = require('path')

// From https://github.com/toniov/p-iteration/blob/master/lib/static-methods.js - MIT © Antonio V
const forEach = async (array, callback) => {
Expand Down Expand Up @@ -85,7 +86,11 @@ const copy = async (src, dest, deleteOrphaned, exclude) => {
for (const file of destFileList) {
if (srcFileList.indexOf(file) === -1) {
core.debug(`Found a orphaned file in the target repo - ${ dest }${ file }`)
await fs.remove(`${ dest }${ file }`)
if (exclude.includes(path.join(src, file))) {
core.debug(`Excluding file ${ file }`)
} else {
await fs.remove(`${ dest }${ file }`)
}
}
}
}
Expand Down

0 comments on commit 013b028

Please sign in to comment.