Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
10 changes: 10 additions & 0 deletions lib/ncp.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down