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

Use the same replace in multiple pipes #21

Open
josdejong opened this issue Jul 26, 2014 · 10 comments
Open

Use the same replace in multiple pipes #21

josdejong opened this issue Jul 26, 2014 · 10 comments
Labels

Comments

@josdejong
Copy link

When I use the same replace in two pipes, one of the two pipes seemst to fail.

I try something like this:

var replace = require('gulp-replace');

var replaceStuff = replace(/foo/, function (match) {
  // ... do stuff...
  return 'bar';
});

return gulp.src('path')
      .pipe(replaceStuff)
      .pipe(gulp.dest('dest'));

return gulp.src('other/path')
      .pipe(replaceStuff)
      .pipe(gulp.dest('other/dest'));

Is this a bug or am I overlooking something?

@lazd
Copy link
Owner

lazd commented Jul 26, 2014

What do you mean by "fail?" Have you tried using /foo/g?

@josdejong
Copy link
Author

"fail" in the sense that no files come through one of the two pipes when I use the same replaceStuff for both, and when I create a separate replaceStuff for both pipes, it works fine and both pipes output (transformed) files.

@josdejong
Copy link
Author

I'm trying to write a small example to demonstrate the issue, but the issue doesn't show up in a simple example. I will let you know as soon as I can repeat this issue - maybe it turns out to be a bug in my gulpfile.

@lazd
Copy link
Owner

lazd commented Jan 21, 2015

@josdejong any update on this? Still an issue?

@josdejong
Copy link
Author

Thanks for your reply. I haven't found a solution, instead I just created two separate instances of gulp-replace to work around the issue.

I have just updated all depencencies, and the issue is still the case.

I'm not sure whether the cause is in my gulpfile, in gulp-replace, or in gulp itself. If you are interested to have a look at it, you can reproduce the issue as follows:

  • clone the gh-pages branch of mathjs: https://github.com/josdejong/mathjs/tree/gh-pages

  • run npm install in the root of the project

  • run gulp

  • verify that after running gulp, there is a folder /docs containing the docs, which is how it should be.

  • open the file gulpfile.js, and change line 207 from:

    .pipe(injectPermalinks2)

    into:

    .pipe(injectPermalinks)

    here, injectPermalinks is an instance of gulp-replace, defined on lines 61-77. After this change, this instance of injectPermalinks is used twice in the gulpfile, in two different tasks which can run in parallel.

  • run gulp again.

  • now, at least on my computer, there is NO folder /docs created after running gulp.

@Lefthandmedia
Copy link

Isn't it that the first replace replaces all the /foo/ with bar so the second replace has no more /foo/ to find?

@josdejong
Copy link
Author

@Lefthandmedia no it's the same replacer but used on a different stream of files.

@lazd
Copy link
Owner

lazd commented Apr 22, 2021

@josdejong is this still an issue?

@josdejong
Copy link
Author

It has been some time 😅 . Yes same issue. When I follow the steps I wrote here #21 (comment), I get the same end result (no docs being generated), but an error is thrown now instead of silence:

Error: write after end
    at writeAfterEnd (...\mathjs-pages\node_modules\readable-stream\lib\_stream_writable.js:288:12)

@lazd
Copy link
Owner

lazd commented Apr 26, 2021

Ah! Well that gives us something to look into. Thank you for following up!

@lazd lazd added the bug label Apr 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants