outaTiME / grunt-replace

Replace text patterns with applause.
MIT License
411 stars 47 forks source link

Fails when a pattern replacement is an empty string #74

Closed gmetais closed 9 years ago

gmetais commented 9 years ago

Hi and thank you for your work!

I'm having an issue with the latest version (v.0.9.1). I'm setting a pattern, and when the replacement is a empty string, the task fails.

Gruntfile.js:

    replace: {
            dist: {
                options: {
                    patterns: [
                        {
                            match: 'googleAnalyticsId',
                            replacement: ''
                           // my actual replacement string is '<%= settings.gaId %>'
                           // but this value can be empty
                        }
                    ]
                },
                files: [
                    {expand: true, flatten: true, src: ['front/src/main.html'], dest: 'front/build/'}
                ]
            }
        }

The outputed error doesn't tell much:

Running "replace:dist" (replace) task
Verifying property replace.dist exists in config...OK
Files: front/src/main.html -> front/build/main.html
Options: encoding="utf8", processContentExclude=[], mode=false, patterns=[{"match":"googleAnalyticsId","replacement":""},{"match":"version","replacement":"v1.4.1"}], excludeBuiltins=false, force, silent=false
Reading front/src/main.html...OK
Processing source...ERROR
Warning: Error while processing "front/src/main.html" file. Use --force to continue.
outaTiME commented 9 years ago

Oups, i will check asap ...

thks pal, probably this issue was a part of the last update ...

outaTiME commented 9 years ago

Fixed in 0.9.2, sorry pal my fault ... update the npm depenceny =)

thks !

gmetais commented 9 years ago

Works great! Thank you!