- Đây là README và các ví dụ: https://github.com/gruntjs/grunt-contrib-copy/blob/master/README.md .
- Đây là phần có liên quan của mã (mà tôi dường như không thể hiểu được) từ https://github.com/gruntjs/grunt-contrib-copy/blob/master/tasks/copy.js :
module.exports = function (grunt) {
'Sử dụng nghiêm ngặt';
var path = request ('path');
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 (tùy chọn, 'Tùy chọn');
var đích;
var isExpandedPair;
var tally = {
dirs: 0,
tệp: 0
}
this.files.forEach (function (filePair) {
isExpandedPair = filePair.orig.expand || sai;
filePair.src.forEach (function (src) {
if (DetDestType (filePair.dest) === 'thư mục') {
dest = (isExpandedPair)? filePair.dest: unixifyPath (path.join (filePair.dest, src));
} khác {
dest = filePair.dest;
}
if (grunt.file.isDir (src)) {
grunt.verbose.writeln ('Đang tạo' + dest.cyan);
grunt.file.mkdir (dest);
tally.dirs ++;
} khác {
grunt.verbose.writeln ('Đang sao chép' + src.cyan + '->' + dest.cyan);
grunt.file.copy (src, dest, copyOptions);
tally.files ++;
}
});
});
Bạn có biết rằng câu trả lời được chấp nhận là không chính xác? Xem câu trả lời này bên dưới .
—
David Pärsson