Skip to content

Commit

Permalink
fix: ensure the file has the right permission before moving
Browse files Browse the repository at this point in the history
  • Loading branch information
PippoRaimondi committed Mar 10, 2022
1 parent 59a9386 commit a1535e6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ const getCompareSnapshotsPlugin = on => {
on('after:screenshot', details => {
// Change screenshots file permission so it can be moved from drive to drive
setFilePermission(details.path, 0o777)
setFilePermission(paths.image.comparison(details.name), 0o777)
renameAndMoveFile(details.path, paths.image.comparison(details.name))
})

Expand Down
6 changes: 4 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ const readDir = dir => {

const setFilePermission = (dir, permission) => {
try {
const fd = fs.openSync(dir, 'r')
fs.fchmodSync(fd, permission)
if (fs.existsSync(dir)) {
const fd = fs.openSync(dir, 'r')
fs.fchmodSync(fd, permission)
}
} catch (error) {
// eslint-disable-next-line no-console
console.log(error)
Expand Down

0 comments on commit a1535e6

Please sign in to comment.