我使用grunt.file.expand抓取文件夹的内容,并且在链接的forEach中,任何带有.gitkeep,.gitattribute等的文件都没有在** / * globbing模式中被拾取。你如何使用grunt以通配模式获取这些类型的命名文件?抛出/ commands中的错误,这只是包含.gitkeep文件的文件夹之一(也只是文件夹中的文件)。
"Unable to read bower\components\project\app\commands file"
代码段:
// Return unique array of all file paths, which match globbing pattern
var options = {
cwd: srcPath
};
var globPatterns = ['app/**/*',
'bootstrap/**/*',
'public/**/*']
grunt.file.expand( options, globPatterns ).forEach( function ( srcPathRelCwd ) {
// Copy a source file to a destination path, creating directories if necessary
grunt.file.copy(
// Node API join to keep this cross-platform
path.join( srcPath, srcPathRelCwd ),
path.join( destPath, srcPathRelCwd )
);
} );
更新
为选项添加了过滤器,这会让我跳过错误,但是有些文件夹不会被包含在其中的文件创建,例如带有.gitkeep文件的/ app /命令。
// Return unique array of all file paths, which match globbing pattern
var options = {
cwd: srcPath,
filter: 'isFile'
};
答案 0 :(得分:1)
// Return unique array of all file paths, which match globbing pattern
var options = {
cwd: srcPath,
filter: 'isFile',
dot: true // include .files even if not in globbing pattern
};