Git Product home page Git Product logo

Comments (3)

matatk avatar matatk commented on September 28, 2024

I think this would help me, too. I have a task that converts an SVG to several PNGs in a destination folder. This takes some time, so I only really want to run it again when the single src SVG file has changed. But grunt-newer always runs the SVG-to-PNGs task because it expects to find a file in the dest directory with the same name as the source SVG file (of course it won't, because there are multiple dest files with different names and .png instead of .svg for their extensions).

So, I think what we are asking for is:

if dest is a directory:
   treat task as if it were a source-files-only task (only check the timestamp(s) of the source file(s))

Does this make sense? Happy to provide further info if you're interested.

[ Note: I'm trying grunt-newer in a different branch to the one I linked to above, which is why it's not in the Gruntfile (yet) ]

from grunt-newer.

sevarubbo avatar sevarubbo commented on September 28, 2024

@matatk Check out my fork, where I fixed this issue: sevarubbo/grunt-newer. Since it looks like this project is not being supported for quite a long time, I think the only option is to make forks :)

It's quite easy to use, actually. In your package.json just replace "grunt-newer": "^1.2.0" with "grunt-newer": "sevarubbo/grunt-newer"

from grunt-newer.

matatk avatar matatk commented on September 28, 2024

Hi @sevarubbo, and thanks for your reply. I checked out your fork, and it does exactly what you said it does; thanks. However, I now realise this is not actually exactly what I need...

My problem is that when I configure grunt-phantom-rasterize to generate output files in the correct output directory, grunt-newer thinks that the output files are not there, and always re-runs the task. This is the output from grunt -v

Running "newer:rasterize:chrome" (newer) task
Options: cache="/Users/matatk/projects/landmarks/node_modules/grunt-newer/.cache", override=undefined, tolerance=0
Files: src/assemble/landmarks.svg -> ../../cache/landmarks.svg

The problem is that the output files have names like "landmarks-32.png" and "landmarks-48.png" and not just "landmarks.svg". My current files objects look like this:

                    files: [{
                        expand: true,
                        cwd: srcAssembleDir,
                        src: 'landmarks.svg',
                        dest: path.join('..', '..', pngCacheDir)
                    }]

I did try to reconfigure the files object in my Gruntfile in order to ensure that grunt-newer sees dest as a directory:

                    files: [{
                        src: path.join(srcAssembleDir, 'landmarks.svg'),
                        dest: path.join('..', '..', pngCacheDir)
                    }]

In this case, your fork of grunt-newer behaves perfectly, detecting that dest is a directory and ignoring it if landmarks.svg has not changed.

Running "newer:rasterize:chrome" (newer) task
Options: cache="/Users/matatk/projects/landmarks/node_modules/grunt-newer/.cache", override=undefined, tolerance=0
Files: src/assemble/landmarks.svg -> ../../cache

However, when I set up the files object in this way, grunt-phantom-rasterize always outputs the PNG files in the root directory of the repo, rather than the "cache" directory.

I can think of a hacky solution: simply move the PNG files to the cache directory when they have been generated, but this feels totally wrong.

However, this is now somewhat off topic for grunt-newer I think! So I will try to figure it out. Thanks to @tschaub for writing this in the first place and to you @sevarubbo for your updates.

Update: actually I just re-checked and grunt-newer doesn't work if I use ../../cache as the dest path, as it appears that grunt-newer is treating dest as relative to Gruntfile.js, but grunt-phantom-rasterize is treating dest as relative to src. My head hurts! :-) Suspect I'm making a n00b error here; will keep researching...

from grunt-newer.

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.