diff --git a/README.md b/README.md index 9480032..90af3a8 100644 --- a/README.md +++ b/README.md @@ -60,4 +60,6 @@ You can also call ncp like `ncp(source, destination, options, callback)`. * `options.errs` - stream. If `options.stopOnErr` is `false`, a stream can be provided, and errors will be written to this stream. + * `options.warns` - stream of warnings (like a destination file already existing when clobber=false). + Please open an issue if any bugs arise. As always, I accept (working) pull requests, and refunds are available at `/dev/null`. diff --git a/lib/ncp.js b/lib/ncp.js index 96eed47..7591c4d 100644 --- a/lib/ncp.js +++ b/lib/ncp.js @@ -94,6 +94,16 @@ function ncp (source, dest, options, callback) { rmFile(target, function () { copyFile(file, target); }); + } else { + var warns = options.warns; + var warn = "destination file '" + target + "' already exists, skipping"; + if (warns) { + if (typeof warns.write === 'undefined') { + warns.push(warn); + } else { + warns.write(warn); + } + } } if (modified) { var stat = dereference ? fs.stat : fs.lstat;