Node-fs-extra: Additional param for options.filter() on copy()

Created on 6 Feb 2017  路  9Comments  路  Source: jprichardson/node-fs-extra

At the moment when using copy(), the options.filter() function receives the source path as it's only param. It would be nice to have both the source and destination paths:

fs.copy(srcFolder, destFolder, {
  filter: (srcPath, destPath) => {
    return true
  }
}, cb)

This would make checking last mod dates much easier.

enhancement feature-copy

All 9 comments

@jprichardson ?

My filters are breaking after upgrade to 2.0.0: This doesn't copy anymore.

var onlyWoff = function (fn) {
    return fn.endsWith('.woff');
};
fs.copySync('src/na_components/dist-nwf/theme/fonts', 'dist/na_components/dist-nwf/theme/fonts', { filter: onlyWoff });

I second that; the dest parameter is exactly what I need.

@jprichardson should this be implemented?

@jprichardson should this be implemented?

Yes, seems reasonable to me!

@stephen-last @manidlou Interested in working on this?

@stephen-last if you feel like adding this feature please go ahead and when you are done submit PR, otherwise I will do it.

@manidlou I would love to contribute, however I haven't actually contributed to someone else's code base before, so I'd have to learn how first. I think learning this is probably better done on a smaller project rather than one as important as this one. Feel free to do this one. Thanks!

@stephen-last I am learning too, or I'd better say I never stop learning! :smiley:. I hope you have a wonderful and thriving experience in the journey of educating yourself! Your help is always appreciated here!

Was this page helpful?
0 / 5 - 0 ratings