- นี่คือ README และตัวอย่าง: 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 (ฮึดฮัด) {
'ใช้อย่างเข้มงวด';
var path = ต้องใช้ ('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 (ตัวเลือก 'ตัวเลือก');
var dest;
var isExpandedPair;
var tally = {
dirs: 0,
ไฟล์: 0
};
this.files.forEach (ฟังก์ชัน (filePair) {
isExpandedPair = filePair.orig.expand || เท็จ;
filePair.src.forEach (ฟังก์ชัน (src) {
ถ้า (detectDestType (filePair.dest) === 'ไดเร็กทอรี') {
ปลายทาง = (isExpandedPair)? filePair.dest: unixifyPath (path.join (filePair.dest, src));
} else {
dest = filePair.dest;
}
ถ้า (grunt.file.isDir (src)) {
grunt.verbose.writeln ('กำลังสร้าง' + dest.cyan);
grunt.file.mkdir (dest);
tally.dirs ++;
} else {
grunt.verbose.writeln ('คัดลอก' + src.cyan + '->' + dest.cyan);
grunt.file.copy (src, dest, copyOptions);
นับไฟล์ ++;
}
});
});