Giter Site home page Giter Site logo

Adds file back to the stream with wrong path (i.e. path changes that happened after gulp-remember are already applied) about gulp-remember HOT 4 CLOSED

ahaurw01 avatar ahaurw01 commented on June 25, 2024
Adds file back to the stream with wrong path (i.e. path changes that happened after gulp-remember are already applied)

from gulp-remember.

Comments (4)

ahaurw01 avatar ahaurw01 commented on June 25, 2024

Thanks for the ticket, @smessmer. This kind of problem can occur when your pipe to remember() comes before another pipe that mutates the files. When you rename() the files, this mutates the file object and thus affects the files in the remember cache.

You can confirm this by putting some logging in node_modules/gulp-remember/index.js if you are curious. For example,

  • util.log('REMEMBERING FILE', file.path); inside the transform function.
  • util.log('RECALLING FILE', path, '(' + cache[path].path + ')') inside the flush loop.

You'll see that the recalled path inside parens differs from the original path because it was mutated.

There are a few options for you:

  • Split apart your processing a little bit and pipe to gulp.dest('build/resources').
  • Simply swap your pipes to remember() and rename(). This is probably easiest.

In a similar example, you wouldn't want to remember() a .coffee file and then send it through the coffeescript transpiler afterward. This would risk re-transpiling an already transpiled file. You would instead transpile it, remember it, then do anything with it that does not require mutating the file, like concatenate with other files, for example.

Let me know if this helps. If so, I'll leave it to you to answer your stack overflow post with the gist of the concept here and the solution that worked for you.

from gulp-remember.

smessmer avatar smessmer commented on June 25, 2024

Hey,

thank you for the fast answer :)
Unfortunately, I can't swap remember() and rename(), because remember() is called inside a module and rename() outside of that. Our build is quite complex, using multiple remember caches in different sub modules. And we can't split the build, because in the end, we zip all files together, which needs us to have all files in one stream.

Our current workaround is a check in the rename module that checks whether the resource directory name has already been prepended. That works, but is a (quite hacky) workaround and would not work for other instances (for example when there are input files in a resource/* subfolder that should be copied to resource/resource/* correspondingly).

Is there a specific reason for gulp-remember behaving this way? I'd find it much more logical if it remembered the files as they actually passed through it. Since the output stream of gulp-remember always passes the same future processing, no matter whether it is the first run or a later run, gulp-remember also should output the files in the same way in each run. Later runs should not output different files than the first run remembered.

from gulp-remember.

alexander-akait avatar alexander-akait commented on June 25, 2024

@ahaurw01 I have some problem. May be add options base to calculation path.

from gulp-remember.

ahaurw01 avatar ahaurw01 commented on June 25, 2024

As mentioned in PR #19, gulp-clone may be a good option here.

from gulp-remember.

Related Issues (15)

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.