Skip to content

Commit

Permalink
Make copy-readonly-dir.test.js consistent with copy-sync test
Browse files Browse the repository at this point in the history
  • Loading branch information
mbargiel committed Jul 9, 2018
1 parent 648ac52 commit 69969ab
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/copy/__tests__/copy-readonly-dir.test.js
Expand Up @@ -35,10 +35,20 @@ describe('+ copy() - copy a readonly directory with content', () => {
FILES.forEach(file => {
fs.outputFileSync(path.join(TEST_DIR, file), file)
})
klawSync(TEST_DIR).forEach(data => fs.chmodSync(data.path, data.stats.isDirectory() ? 0o555 : 0o444))

fse.copy(path.join(TEST_DIR, 'dir1'), path.join(TEST_DIR, 'target'), err => {
const sourceDir = path.join(TEST_DIR, 'dir1')
const sourceHierarchy = klawSync(sourceDir)
sourceHierarchy.forEach(source => fs.chmodSync(source.path, source.stats.isDirectory() ? 0o555 : 0o444))

const targetDir = path.join(TEST_DIR, 'target')
fse.copy(sourceDir, targetDir, err => {
assert.ifError(err)

// Make sure copy was made and mode was preserved
assert(fs.existsSync(targetDir))
const targetHierarchy = klawSync(targetDir)
assert(targetHierarchy.length === sourceHierarchy.length)
targetHierarchy.forEach(target => assert(target.stats.mode === target.stats.isDirectory() ? 0o555 : 0o444))
done()
})
})
Expand Down

0 comments on commit 69969ab

Please sign in to comment.