gruntjs - How do I reuse a grunt copy task for multiple destinations dynamically? -


instead of adding destinations in dest attribute make dynamic can assign destinations when run task command line or when run task. way can copy file folder(s) want whenever call task.

copy: {         nightlybuild: {             files: [{                 expand: true,                 cwd: '../',                 src: ['index.html'],                 dest: 'destinations'             }]          }       }, 

i assuming need use grunt.option , grunt.config can't seem right. have multiple scripts reuse in similar way.

i think in right track. should help

copy: {     nightlybuild: {         files: [{             expand: true,             cwd: '../',             src: ['index.html'],             dest: '<%= dest %>',         }]     } },  grunt.task.registertask('copyto', 'copy specific destination', function(dest) {   if (arguments.length === 0) {     grunt.log.writeln(this.name + ", missing destination");   } else {     grunt.log.writeln(this.name + " " + dest);     grunt.config.set('dest', dest);      grunt.task.run([       'copy:nightlybuild'     ]);   } }); 

you call task this: grunt copyto:mydestination


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -