Giter Club home page Giter Club logo

Comments (10)

millermedeiros avatar millermedeiros commented on May 29, 2024

I'm thinking that gulp.src could be maybe 4 modules:

  1. one that converts the globs into a Stream of files that only contains the paths (no content or stats).
  2. a filereader-stream that adds the content to the paths info.
  3. a filestats-stream that adds the stats to the paths info.
  4. one that encapsulates all of them for brevity.

and gulp.dest could be just a filewriter-stream that simply does mkdirp and fs.createWriteStream based on the file.path and file.content.

I've been looking for a good API to read files from multiple directories, and process them before copying to a destination for a long time. This might be the one, since it allows piping multiple transforms in a easy way.

from gulp.

yocontra avatar yocontra commented on May 29, 2024

Rambling a bit here...

@millermedeiros I can merge the file format into the output of glob-stream (the path info, not contents). The filestats streams takes this and attaches the stats object. The filereader stream takes this and based on X args (buffer: true, read: false, etc.) and the file.stats creates file.contents. The fileread needs filestats to be executed on the file object otherwise it won't know how to read directories correctly.

Is this what you're suggesting? Thoughts?

from gulp.

millermedeiros avatar millermedeiros commented on May 29, 2024

It was just an idea, did not put too much thought into that. In fact not
even sure what would be the best format and if the "plugins" should expose
just an async method...

from gulp.

phated avatar phated commented on May 29, 2024

Gulp isn't too big, and the file streams could be used without the task management. I see no reason for the decouple.

from gulp.

millermedeiros avatar millermedeiros commented on May 29, 2024

@phated the problem is not the "size" of gulp, but that at the moment this tool have 4 different responsibilities which are not necessarily closely related:

  1. it's a task runner (delegates work to orchestrator)
  2. it's a file watcher (delegates work to gaze)
  3. it's an argument parser (delegates work to optimist)
  4. it's a file processor based on Streams (currently implemented internally)

since responsibilities 1, 2 and 3 are handled by external tools, I think this should also be part of an external package and gulp would just glue the external tools together and provide an unified API (maybe not even necessary). - I don't need that many unrelated dependencies (arguments parser, file watcher and task runner) just to process files.

this is not a problem of file size, but just that smaller tools with single responsibilities are easier to grok and can evolve independently (size of the README would reduce considerably). I would really like to see a future where we can reuse modules without having to code yet another plugin for a different runner... and Streams are a good abstraction for some file operations because they can be piped and doesn't require whole file to be in memory (even tho most examples I saw doesn't benefit from that).

from gulp.

phated avatar phated commented on May 29, 2024

Instead, you are advocating for yet another file streaming style. This
style is unique to gulp and doesn't really matter standalone. Gulp doesn't
require plugins, just JS, which is where most of your confusion seems to be
coming from. The reason to make a plugin is to tell people it expects that
style of file stream.
On Nov 30, 2013 11:40 AM, "Miller Medeiros" [email protected]
wrote:

@phated https://github.com/phated the problem is not the "size" of
gulp, but that at the moment this tool have 4 different responsibilities
which are not necessarily closely related:

  1. it's a task runner (delegates work to orchestrator)
  2. it's a file watcher (delegates work to gaze)
  3. it's an argument parser (delegates work to optimist)
  4. it's a file processor based on Streams (currently implemented
    internally)

since responsibilities 1, 2 and 3 are handled by external tools, I think
this should also be part of an external package and gulp would just
glue the external tools together and provide an unified API (maybe not
even necessary). - I don't need that many unrelated dependencies (arguments
parser, file watcher and task runner) just to process files.

this is not a problem of file size, but just that smaller tools with
single responsibilities are easier to grok and can evolve independently
(size of the README would reduce considerably). I would really like to see
a future where we can reuse modules without having to code yet another
plugin
for a different runner... and Streams are a good abstraction for
some file operations because they can be piped and doesn't require
whole file to be in memory (even tho most examples I saw doesn't benefit
from that).


Reply to this email directly or view it on GitHubhttps://github.com//issues/28#issuecomment-29558195
.

from gulp.

millermedeiros avatar millermedeiros commented on May 29, 2024

@phated I'm advocating a standalone file stream standard (same as what you guys currently have), in the hopes of it becoming widely used in different contexts, and that users understands the benefits of Streams over regular callbacks for some tasks... I'll elaborate better about plugins on a separate issue. - xkcd on standards

from gulp.

yocontra avatar yocontra commented on May 29, 2024

Okay so I broke the file object out into https://github.com/wearefractal/vinyl and I'm breaking the read/write for the FS into vinyl out into https://github.com/wearefractal/vinyl-fs

from gulp.

yyx990803 avatar yyx990803 commented on May 29, 2024

+1. vinyl-fs actually allows most gulp plugins to be used anywhere, e.g. inside grunt tasks.

from gulp.

yocontra avatar yocontra commented on May 29, 2024

Closing this - vinyl-fs is coming in the next release

from gulp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.