Skip to content

Add jamen/pull-fs-meta #18

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

Closed
wants to merge 1 commit into from
Closed

Add jamen/pull-fs-meta #18

wants to merge 1 commit into from

Conversation

jamen
Copy link
Contributor

@jamen jamen commented Oct 25, 2016

Hello, back with another module, pull-fs-meta. This one is experimental, but seems to be pretty cool so far. It's my approach to an fs module on pull-stream.

It appears to operate much like Vinylinside gulp, except it actually just streams the file contents, and manages the metadata behind the scenes. That way you can have reusable pull-* modules that compile contents (like pull-css) operate like a build system with this, without need to create wrappers and whatnot:

var fs = require('pull-fs-meta')()
var css = require('pull-css')

pull(
  // Read file contents:
  fs.read('out/*.css'),
  // Parse contents as CSS:
  css(),
  // Then transform AST, like PostCSS
  // Stringify it after transformed:
  css.stringify(),
  // And write out
  fs.write('out')
)

@dominictarr
Copy link
Member

curious: does this return a stream of streams, or does it concatenate all the streams?

@dominictarr
Copy link
Member

it might be interesting to use with http://npm.im/tar-fs

@jamen
Copy link
Contributor Author

jamen commented Oct 25, 2016

does this return a stream of streams, or does it concatenate all the streams?

I don't understand completely 😅. But I'm pretty sure it doesn't return streams of streams. Maybe I can explain.

The functions are created in a factory:

var fs = require('pull-fs-meta')()

They share this private array called meta in that scope. This avoid having to put it on/around the contents itself (like Vinyl).

fs.read resolves globs to paths then reads to contents, and pushes metadata on meta about the file is just read. (For now just [path, base]). Each read correlates with an index on meta.

fs.files is a passthrough stream that is made for changing meta. (For things like extension name, moving files, clearing the metadata, etc.)

fs.write keeps an index for each write call so it can pick the info from meta with the correlating contents it read. (Because the 1:1 read/write ratio)

@jamen
Copy link
Contributor Author

jamen commented Oct 25, 2016

I'm going to redo the name and stuff. I'll open up a new PR later.

@jamen jamen closed this Oct 25, 2016
@jamen jamen deleted the jamen-pull-fs-meta branch October 25, 2016 15:43
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

Successfully merging this pull request may close these issues.

2 participants