Skip to content

Commit

Permalink
Dotfile should be filtered even when referenced as a direct copy e.g.…
Browse files Browse the repository at this point in the history
… copy(".dotfile")
  • Loading branch information
zachleat committed Dec 6, 2024
1 parent 69a2e49 commit 472f896
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ module.exports = function(src, dest, options, callback) {
})
.then(function(filePaths) {
if (options.debug) { log('Filtering source paths…'); }
// must filter out explicit copy attempts for dot files (not post-relative path)
filePaths = getFilteredPaths(filePaths, undefined, {
dot: options.dot,
junk: options.junk
});
var relativePaths = filePaths.map(function(filePath) {
return path.relative(src, filePath);
});
Expand Down
15 changes: 15 additions & 0 deletions test/spec/copy.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,21 @@ describe('copy()', function() {
});
});

it('should not copy dotfiles if dotfile is referenced directly', function() {
return copy(
getSourcePath('dotfiles/.a'),
getDestinationPath()
).then(function(results) {
return getOutputFiles()
.then(function(files) {
var actual, expected;
actual = files;
expected = {};
expect(actual).to.eql(expected);
});
});
});

it('should copy dotfiles if dotfiles is specified', function() {
return copy(
getSourcePath('dotfiles'),
Expand Down

0 comments on commit 472f896

Please sign in to comment.