Skip to content
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

Convenience fs methods #824

Closed
sindresorhus opened this issue Jun 22, 2015 · 4 comments
Closed

Convenience fs methods #824

sindresorhus opened this issue Jun 22, 2015 · 4 comments

Comments

@sindresorhus
Copy link
Member

This is a very common operation, but it's very verbose.

this.fs.copy(this.templatePath('editorconfig'), this.destinationPath('.editorconfig'));

Would be nice to have a yeoman specific convenience wrapper that called templatePath and destinationPath for you:

this.fs.copyFoo('editorconfig', '.editorconfig');

Where copyFoo gets a better name.

Same with copyTpl.

Example of how verbose it gets:

sindresorhus/generator-gulp-plugin-boilerplate@d7503c0#diff-2018087f584c4398b5c3a23fc0e5f9dbR53

@kevva
Copy link
Member

kevva commented Jun 22, 2015

Same with .copyTpl?

@arthurvr
Copy link
Member

👍

@SBoudrias
Copy link
Member

Sorry for the late answer, but here it is!

I considered this when designing this initial API and decided to not do anything about it at this point. There's in my opinion a pretty high complexity cost to automatically combine paths in files methods.

The main issue here is being consistent in our API. As it's very easy to see how useful it would be in the case of copy, it doesn't really make sense for the read/write methods. Can we really assume someone would always want to read from their template folder? Probably not.

Considering this, it would be very inconsistent to have different behavior between our file system helpers.

Without a better idea, I decided to go the verbose paths for now. I hoped globbing support (e.g. fs.copyTpl(this.templatePath('**'), this.destinationPath())) would help making this a minor annoyance.

An option I also considered is to rename this.templatePath() to this.tpl() or this.src() so it would be more brief in release 1.0. I'm open to any other suggestions. The only thing is that I'm sure having implicit path prefix on some methods is a bad idea as it'll break our API consistency.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 2, 2020

This issue is stale because it has been open 15 days with no activity. Remove stale label or comment or this will be closed in 5 days

@github-actions github-actions bot added the stale label Jan 2, 2020
@github-actions github-actions bot closed this as completed Jan 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants