gruntjs - grunt-contrib-copy syntax for process option confusion -


i'm trying replace placeholders in different files copy. gruntfile works fine, adding in process option replacements, it's not working. below relevant section of gruntfile:

grunt.initconfig({      copy: {         js: {             files: [{                 expand: true,                 cwd: 'src/wp-content/themes/pilau-starter/',                 src: ['**/*.js'],                 dest: 'public/wp-content/themes/pilau-starter/'             }],             options: {                 process: function ( content ) {                     console.log( content );                     content = content.replace( /pilaubreakpointlarge/g, breakpoints.large );                     content = content.replace( /pilaubreakpointmedium/g, breakpoints.medium );                     return content;                 }             }         },     }  }); 

the paths can understood in context of code on github: https://github.com/pilau/starter (the public directory isn't committed repo because it's starter theme). paths variables in original gruntfile, , working fine in other tasks.

all vars set ok. i've included console.log( content ) check if process function's running - doesn't seem be, guess it's basic syntax.

there's answer (https://stackoverflow.com/a/28600474/1087660) seems address this, far can tell, way of doing bad js syntax - not sure how got marked right.

--verbose output running copy task:

running "copy:js" (copy) task verifying property copy.js exists in config...ok files: src/wp-content/themes/pilau-starter/js/admin.js -> public/wp-content/themes/pilau-starter/js/admin.js files: src/wp-content/themes/pilau-starter/js/flickity.js -> public/wp-content/themes/pilau-starter/js/flickity.js files: src/wp-content/themes/pilau-starter/js/global.js -> public/wp-content/themes/pilau-starter/js/global.js files: src/wp-content/themes/pilau-starter/js/modernizr.js -> public/wp-content/themes/pilau-starter/js/modernizr.js files: src/wp-content/themes/pilau-starter/js/picturefill.js -> public/wp-content/themes/pilau-starter/js/picturefill.js files: src/wp-content/themes/pilau-starter/js/respond.js -> public/wp-content/themes/pilau-starter/js/respond.js options: processcontent=false, processcontentexclude=[], process=undefined options: processcontent=false, processcontentexclude=[], process=undefined copying src/wp-content/themes/pilau-starter/js/admin.js -> public/wp-content/themes/pilau-starter/js/admin.js reading src/wp-content/themes/pilau-starter/js/admin.js...ok writing public/wp-content/themes/pilau-starter/js/admin.js...ok 

your version of grunt-contrib-copy 0.4.0. correctly point out @nemesv above property name use in version processcontent not process.

i cloned repo , switched json-breakpoints branch. , ran grunt copy:js , replaced content.

original-content replaced-content

now,when run grunt copy:js --verbose still show this

cli

processcontent logged undefined because grunt uses json.stringify log value. , json.stringify returns undefined when pass function definition.


if interested, here's method reponsible logging option

    log.prototype.writeflags = function(obj, prefix) {         var wordlist;         if (array.isarray(obj)) {             wordlist = this.wordlist(obj);         } else if (typeof obj === 'object' && obj) {             wordlist = this.wordlist(object.keys(obj).map(function(key) {                 var val = obj[key];                 return key + (val === true ? '' : '=' + json.stringify(val));             }));         }         this._writeln((prefix || 'flags') + ': ' + (wordlist || '(none)'.cyan));         return this;     }; 

Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -