Skip to content

Commit

Permalink
add option to skip special files (#15)
Browse files Browse the repository at this point in the history
* add option to skip special files

* use stat object

* check if directly, make sure we have a.stat first
  • Loading branch information
joehand authored and mafintosh committed Apr 24, 2018
1 parent 1ed42a7 commit 94504a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Expand Up @@ -36,8 +36,9 @@ Options include:
dereference: false, // dereference any symlinks
equals: fun, // optional function to determine if two entries are the same, see below
ignore: null, // optional function to ignore file paths on src or dest
dryRun: false // emit all events but don't write/del files,
keepExisting: false // whether to delete extra files in the destination that are not present in the source
dryRun: false, // emit all events but don't write/del files,
keepExisting: false, // whether to delete extra files in the destination that are not present in the source
skipSpecial: true // skip any files that are not regular files
}
```

Expand Down
6 changes: 6 additions & 0 deletions index.js
Expand Up @@ -9,6 +9,7 @@ module.exports = mirror
function mirror (src, dst, opts, cb) {
if (typeof opts === 'function') return mirror(src, dst, null, opts)
if (!opts) opts = {}
if (opts.skipSpecial !== false) opts.skipSpecial = true

var progress = new events.EventEmitter()
progress.destroy = destroy
Expand Down Expand Up @@ -89,6 +90,11 @@ function mirror (src, dst, opts, cb) {
// copy to b
if (a.stat && !b.stat) return put(a, b, next)

if (!a.stat.isDirectory() && opts.skipSpecial && !a.stat.isFile()) {
progress.emit('skip', a, b)
return next()
}

// check if they are the same
equals(a, b, function (err, same) {
if (err) throw err
Expand Down

0 comments on commit 94504a0

Please sign in to comment.