什么是“扩大”选项做在grunt-contrib-copy?这些例子都使用它,但文档没有说明它的功能 [英] What does the "expand" option do in grunt-contrib-copy? The examples all use it but the docs say nothing about what it does
本文介绍了什么是“扩大”选项做在grunt-contrib-copy?这些例子都使用它,但文档没有说明它的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
- 以下是自述文件和示例: 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) {
'use strict';
var path = require('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(options, 'Options');
var dest;
var isExpandedPair;
var tally = {
dirs: 0,
files: 0
};
this.files.forEach(function(filePair) {
isExpandedPair = filePair.orig.expand || false;
filePair.src.forEach(function(src) {
if (detectDestType(filePair.dest) === 'directory') {
dest = (isExpandedPair) ? filePair.dest : unixifyPath(path.join(filePair.dest, src));
} else {
dest = filePair.dest;
}
if (grunt.file.isDir(src)) {
grunt.verbose.writeln('Creating ' + dest.cyan);
grunt.file.mkdir(dest);
tally.dirs++;
} else {
grunt.verbose.writeln('Copying ' + src.cyan + ' -> ' + dest.cyan);
grunt.file.copy(src, dest, copyOptions);
tally.files++;
}
});
});
推荐答案
Expand让您指定是否要完整地创建目标路径(例如: / path / missing1 / missing2
),或者只在其父目录存在时创建最后一个目录( / path / existing / missing
)。
Expand lets you specify whether you want to create the destination path in full (e.g: /path/missing1/missing2
), or only create the last directory when its parent exists (/path/existing/missing
).
这篇关于什么是“扩大”选项做在grunt-contrib-copy?这些例子都使用它,但文档没有说明它的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文