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

Converter to object mode? #15

Closed
erikras opened this issue Apr 17, 2014 · 5 comments
Closed

Converter to object mode? #15

erikras opened this issue Apr 17, 2014 · 5 comments

Comments

@erikras
Copy link

erikras commented Apr 17, 2014

Greetings. Perhaps this is a stupid n00b question, but...

I've got a library, gulp, that is using through2 in normal (binary?) stream mode, and I'd like to pass my stream through another library, exorcist, which is using through2 in objectMode.

Is there any way to reconcile these streams? Something I could pipe it through?

@dashed
Copy link

dashed commented Apr 17, 2014

@erikras I think gulp uses object mode since each element in the stream is a vinyl object: https://github.com/wearefractal/vinyl

You'll have better luck posting to gulp issues forum.

@laurelnaiad
Copy link

For streams of files, gulp uses objectMode. Are you referring to a particular gulp plugin that is not using objectMode? Or are you referring to a stream of the file contents? If it's a stream of the file contents, I think you're on your own...

@erikras
Copy link
Author

erikras commented Apr 17, 2014

The problem is that exorcist is not an official gulp plugin, and apparently I don't understand node streams well enough to wrap it into a gulp plugin. Exorcist takes command line piped input. It sounds like I'd have to unwrap the vinyl object, pass it through exorcist, and then wrap it again. It seems like a common enough problem that I thought maybe someone had written one.

Thanks for your quick replies.

@erikras
Copy link
Author

erikras commented Apr 17, 2014

Aha!!! I knew this was possible. vinyl-transform to the rescue!

@erikras erikras closed this as completed Apr 17, 2014
@erikras
Copy link
Author

erikras commented Apr 17, 2014

For posterity, this is how you wrap exorcist for gulp:

'use strict';
var gulp = require('gulp'),
  browserify = require('gulp-browserify'),
  transform = require('vinyl-transform'),
  exorcist = require('exorcist'),
  concat = require('gulp-concat');

gulp.task('browserify', function () {
  gulp
    .src('src/app.js')
    .pipe(browserify({
      debug: true
    }))
    .pipe(transform(function () {
      return exorcist('dist/script.map');
    }))
    .pipe(concat('script.js'))
    .pipe(gulp.dest('./dist'));
});

gulp.task('default', ['browserify']);

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