-
-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More parameters for option rename function #48
Comments
This comment has been minimized.
This comment has been minimized.
Hmm, another idea. We would pass the callback two arguments, {
path: '/Users/sindresorhus/foo.txt',
name: 'foo.txt',
nameWithoutExtension: 'foo',
extension: 'txt'
}
I think this would make it really nice to use: const cpy = require('cpy');
(async () => {
await cpy('foo.js', 'destination', {
rename: (source, destination) => {
if (source.nameWithoutExtension === 'foo') {
destination.nameWithoutExtension = 'bar';
}
}
});
})(); If you just want to change the extension, you could do: const cpy = require('cpy');
(async () => {
await cpy('foo.js', 'destination', {
rename: (source, destination) => {
if (source.nameWithoutExtension === 'foo') {
destination.extension = 'ts';
}
console.log(destination.name);
//=> 'foo.ts'
}
});
})(); I think I prefer this approach. |
@sindresorhus This does sound like a nice approach indeed. Was there desire to move ahead with this? |
My above proposal is how it should be implemented. It's not something I plan to work on anytime soon though. However, good PRs are always welcome. |
Hi, first of all, thanks for this amazing library.
I am wondering if it's possible to pass
srcPath
anddest
to rename function here:https://github.com/sindresorhus/cpy/blob/master/index.js#L18
What I want to do is to rename the file with the hash value, so I need srcPath to do that.
Thanks!
The text was updated successfully, but these errors were encountered: