Giter Club home page Giter Club logo

Comments (13)

yocontra avatar yocontra commented on May 30, 2024

You can already use event-stream (or other libraries) to wrap existing node-style (callback) libraries. Not sure this belongs in core.

from gulp.

phated avatar phated commented on May 30, 2024

I agree that this just looks like event-stream and loses most of what makes
gulp awesome. Gulp can already deal with any type of streams but the
gulp.src & gulp.dest functions return streams that have a custom format
that is specific to gulp.
On Nov 30, 2013 1:24 PM, "Eric Schoffstall" [email protected]
wrote:

You can already use event-stream (or other libraries) to wrap existing
node-style (callback) libraries. Not sure this belongs in core.


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

from gulp.

millermedeiros avatar millermedeiros commented on May 30, 2024

exactly, the point of these methods would be to convert the custom Stream data format:

{
  shortened: 'foo.md',
  base: 'doc/',
  path: 'doc/foo.md',
  isDirectory: false,
  stat: { ... },
  contents: <Buffer 23 20 63 ...>
}

into something that other tools would normally use (just the path or contents) + some config..

just cause in my opinion it will commit same mistakes as grunt eventually (many useful tools locked to a single runner for no real benefit).

from gulp.

phated avatar phated commented on May 30, 2024

Plugins aren't locked in. As long as you pass the expected format stream,
they would work anywhere. Grunt plugins won't work anywhere else. Please,
please, please look at both options more deeply before claiming they have
similar problems.
On Nov 30, 2013 1:40 PM, "Miller Medeiros" [email protected] wrote:

exactly, the point of these methods would be to convert the custom Stream
data format:

{
shortened: 'foo.md',
base: 'doc/',
path: 'doc/foo.md',
isDirectory: false,
stat: { ... },
contents: <Buffer 23 20 63 ...>}

into something that other tools would normally use (just the path or
contents) + some config..

just cause in my opinion it will commit same mistakes as grunt eventually
(many useful tools locked to a single runner for no real benefit).


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

from gulp.

millermedeiros avatar millermedeiros commented on May 30, 2024

@phated this is just an advice on how you guys could convert other npm modules into a compatible format without having to write custom plugins (and would also simplify the code of current plugins).

from gulp.

yocontra avatar yocontra commented on May 30, 2024

@millermedeiros I like the idea but I think this belongs in userland. Core is reserved for base functionality not shims for supporting other styles of utilizing the base functionality.

from gulp.

yocontra avatar yocontra commented on May 30, 2024

Especially if we are thinking of splitting out the file format and standardizing it. The compat layer for that standard shouldn't be in gulp

from gulp.

millermedeiros avatar millermedeiros commented on May 30, 2024

just compare the plugin example on the README:

var es = require('event-stream');

module.exports = function(header){
  // check our options
  if (!header) throw new Error("header option missing");

  // our map function
  function modifyContents(file, cb){
    // remember that contents is ALWAYS a buffer
    file.contents = new Buffer(header + String(file.contents));

    // first argument is an error if one exists
    // second argument is the modified file object
    cb(null, file);
  }

  // return a stream
  return es.map(modifyContents);
}

with this implementation:

var gulpMapper = require('gulp-mapper');

module.exports = function(header){
  return gulpMapper.mapFileContentsSync(prepend, header);
};

function prepend(fileContents, str){
  if (!str) throw new Error("header option missing");
  return new Buffer(str + String(fileContents));
}

think of it as a eventStream.map() but for the stream format used by gulp. Could even be a generic method gulpMapper.map() that receives the property name as first argument, like: gulpMapper.mapSync('stat', log) (which would log all the file.stat properties).

from gulp.

yocontra avatar yocontra commented on May 30, 2024

@millermedeiros Still the same opinion. IMO a function that makes writing plugins/streams easier doesn't need to be in core. It belongs in user-land and if proven useful enough in gulp-util

from gulp.

millermedeiros avatar millermedeiros commented on May 30, 2024

@contra sure, it can be on user land as a gulp-mapper module. was more to share my thoughts on what I think could improve the project and reduce the amount of unnecessary plugins (even if it makes the build script a little bit uglier).

from gulp.

yocontra avatar yocontra commented on May 30, 2024

@millermedeiros let me know when you have a repo up I'd love to help out

from gulp.

hparra avatar hparra commented on May 30, 2024

@millermedeiros I just released a yeoman generator if you haven't started yet:

npm install -g generator-gulp-plugin
mkdir gulp-mapper
cd gulp-mapper
yo gulp-plugin

from gulp.

yocontra avatar yocontra commented on May 30, 2024

@hparra Nice! I'll try it out and give some feedback. I can put it in the README next to all of the plugin creation advice

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.