Skip to content

Commit

Permalink
test ignore and .ignore feature
Browse files Browse the repository at this point in the history
  • Loading branch information
alanclarke committed Sep 5, 2015
1 parent 63992d1 commit 89a7b0a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rsync.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = function rsync (src, dest, opts) {
if (hasIgnoreFile) args.push('--exclude-from', path.join(dest, '.ignore'))
if (opts.ignore) {
opts.ignore.forEach(function (file) {
args.push('--exclude', file)
args.push('--exclude', file.replace(src, ''))
})
}
args.push(src, dest)
Expand Down
23 changes: 23 additions & 0 deletions test/rsync-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,28 @@ describe('rsync', function () {
})
})

describe('ignore', function () {
it('should ignore files specified by ignore', function () {
return rsync(paths.src.dir, paths.dest.dir, {
ignore: [ paths.src.transferMe ]
})
.then(shouldExist(paths.dest.transferMe, false))
})
})

describe('.ignore', function () {
beforeEach(function () {
return writeFile(
path.join(paths.dest.dir, '.ignore'),
paths.src.transferMe.replace(paths.src.dir, '')
)
})
it('should ignore files specified by .ignore', function () {
return rsync(paths.src.dir, paths.dest.dir)
.then(shouldExist(paths.dest.transferMe, false))
})
})

function setPaths () {
paths = {}
var folders = ['src', 'dest']
Expand All @@ -82,6 +104,7 @@ describe('rsync', function () {
paths[name].transferMe = path.join(paths[name].dir, 'transferMe')
paths[name].deleteMe = path.join(paths[name].dir, 'deleteMe')
paths[name].allreadyThere = path.join(paths[name].dir, 'allreadyThere')
paths[name]['.ignore'] = path.join(paths[name].dir, 'allreadyThere')
})
}

Expand Down

0 comments on commit 89a7b0a

Please sign in to comment.