我gulpfile可以编辑(变化)和删除文件,但不复制新(加)文件
我试着用gulp.watch和观看(一饮而尽手表),但是当我添加新的文件,不要在dest复制。我gulpfile可以编辑(变化)和删除文件,但不复制新(加)文件
我该怎么做呢?
Thnks!
PD:我使用的版本3.9.1
gulp.task('default', function() {
for(var i = 0; i < origen_web.length ; i++) {
var source = '../..' + '/dir' + '/**/*';
var dist = '../../dist';
watch(source, function(obj){
copyFiles(obj, source, dist);
});
}
}
function copyFiles(source, dist, obj) {
gulp.src(source)
.pipe(gulp.dest(dist));
}
对不起,这是我的代码更加少了。
是的,我使用这个例子,但工作,如果它复制所有文件夹,如果我复制文件的文件更改,不要使用新文件:S –
它扔什么?也许脚本没有这些文件的权限?你可以使用nodejs fs API复制文件来检查吗? https://nodejs.org/api/fs.html –
我发布了一些代码,是的,我有权限,因为这些文件(添加)与复制文件在同一个文件夹中。 –
好了重复的问题,尝试与此有关。
gulp.task('default', function() {
for(var i = 0; i < origen_web.length ; i++) {
var source = '../..' + '/dir' + '/**/*';
var dist = '../../dist';
watch(source, function(obj){
copyFiles(obj, source, dist);
});
}
}
function copyFiles(source, dist, obj) {
return gulp.src(source) // <-- here you force gulp to return the value
.pipe(gulp.dest(dist))
.pipe(notify({message: "This message is triggered if the data has been transferred"}));
}
你可以发布你的gulp文件的例子吗? – mutantkeyboard
我张贴一些代码:) –
https://*.com/questions/22391527/gulps-gulp-watch-not-triggered-for-new-or-deleted-files – Mark