- 这是自述文件和示例:https : //github.com/gruntjs/grunt-contrib-copy/blob/master/README.md。
- 这是来自https://github.com/gruntjs/grunt-contrib-copy/blob/master/tasks/copy.js的代码的相关部分(我显然无法理解):
module.exports = function(grunt){ “使用严格”; var path = require('path'); grunt.registerMultiTask('copy','Copy files。',function(){ var kindOf = grunt.util.kindOf; var options = this.options({ processContent:否, processContentExclude:[] }); var copyOptions = { 流程:options.processContent, noProcess:options.processContentExclude }; grunt.verbose.writeflags(options,'Options'); var dest; var isExpandedPair; var tally = { 目录:0, 档案:0 }; this.files.forEach(function(filePair){ isExpandedPair = filePair.orig.expand || 假; filePair.src.forEach(function(src){ 如果(detectDestType(filePair.dest)==='目录'){ dest =(isExpandedPair)吗?filePair.dest:unixifyPath(path.join(filePair.dest,src)); }其他{ dest = filePair.dest; } 如果(grunt.file.isDir(src)){ grunt.verbose.writeln('Creating'+ dest.cyan); grunt.file.mkdir(dest); tally.dirs ++; }其他{ grunt.verbose.writeln('正在复制'+ src.cyan +'->'+ dest.cyan); grunt.file.copy(src,dest,copyOptions); tally.files ++; } }); });
您是否知道接受的答案不正确?请参阅下面的答案。
—
大卫·派森(DavidPärsson),