我在结构库下面:
src
-common
- asd.ts
- filter.ts
-checking
-hi.json
-third-party
-src
-common
-hello.ts
-two.ts
-three.ts
在这里,我想将文件从 third-party / src / common 移到 src / common ,但是我必须排除 three.ts 文件。
我像下面的bur一样害怕,它会移动所有文件:
gulp.task('common-update', function (done) {
shelljs.cp('-rf', './third-party/angularSB/src/app/common/*', './src/app/common/');
done();
});
答案 0 :(得分:1)
shelljs
的{{1}}函数不能要求您根据目录或通配符进行复制时排除文件。
解决此问题的选项包括:
cp
来复制集合,然后使用cp
删除目标中不需要的特定文件。rm
分别复制每个文件。copyfiles
。答案 1 :(得分:1)
我已经尝试过像这样
gulp.task('common-update', function (done) {
var check = glob.sync('./third-party/src/common/*');
for (var i = 0; i < check.length - 1; i++) {
if (check[i].indexOf('three.ts') === -1) {
shelljs.cp('-rf', check[i], './src/common/');
}
}
done();
});