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

Why is fs an anti-pattern? #383

Closed
jonkemp opened this issue Mar 30, 2014 · 3 comments
Closed

Why is fs an anti-pattern? #383

jonkemp opened this issue Mar 30, 2014 · 3 comments

Comments

@jonkemp
Copy link

jonkemp commented Mar 30, 2014

It's an unwritten rule that gulp plugin developers should not use fs. I would like to know why that is, and if so, what is the alternative?

Use case: you stream html files to a plugin which gets the paths to the externally linked resources and pulls those in. Would you not use fs for that? If not, how would you do it?

@esco
Copy link

esco commented Mar 30, 2014

http://highlandjs.org/

@yocontra
Copy link
Member

@jonkemp Unless your file is at the top of the stream you shouldn't use fs. You should only deal with files that are passed to you.

To solve your example you would read ./html/* and pass it to the plugin instead of passing ./html/index.html and having the plugin resolve the dependencies on the real file system

@yocontra
Copy link
Member

3rd party modules aren't easy to work with though so we have lots of plugins that do resolve dependencies on the fs still. Working to provide tools to fix that for gulp 4 (#357)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants