- Ecco il README e gli esempi: https://github.com/gruntjs/grunt-contrib-copy/blob/master/README.md .
- Ecco la parte rilevante del codice (che apparentemente non riesco a capire) da https://github.com/gruntjs/grunt-contrib-copy/blob/master/tasks/copy.js :
module.exports = function (grunt) { 'usa rigoroso'; var path = require ('percorso'); grunt.registerMultiTask ('copy', 'Copy files.', function () { var kindOf = grunt.util.kindOf; var options = this.options ({ processContent: false, processContentExclude: [] }); var copyOptions = { process: options.processContent, noProcess: options.processContentExclude }; grunt.verbose.writeflags (opzioni, "Opzioni"); var dest; var isExpandedPair; var tally = { dirs: 0, file: 0 }; this.files.forEach (function (filePair) { isExpandedPair = filePair.orig.expand || falso; filePair.src.forEach (function (src) { if (detectDestType (filePair.dest) === 'directory') { dest = (isExpandedPair)? filePair.dest: unixifyPath (path.join (filePair.dest, src)); } altro { dest = filePair.dest; } if (grunt.file.isDir (src)) { grunt.verbose.writeln ("Creazione" + dest.cyan); grunt.file.mkdir (dest); tally.dirs ++; } altro { grunt.verbose.writeln ('Copia' + src.cyan + '->' + dest.cyan); grunt.file.copy (src, dest, copyOptions); tally.files ++; } }); });