问题描述
我在源文件夹中设置了 read-only
属性的图像文件.在大多数情况下,我需要在 gulpfile.js 中多次将它们复制到目标文件夹.
I have image files with read-only
attribute set in source folder. I need to copy them to destination folder in most cases several times in gulpfile.js.
我正在尝试像这样复制 src-to-dest 文件:
I am trying to copy src-to-dest files like this:
gulp.task('copy-images', function () {
gulp.src(path_resource_images + '**/*.jpg')
.pipe(gulp.dest(path_app_images));
});
当 dest 文件夹为空时,它会工作一次.但是对于接下来的所有调用,我都有一个例外,即文件在 dest 文件夹中是 read-only
.如何删除文件属性 read-only
以使 image-copy 每次调用时都能正常工作?
It works once when the dest folder in empty. But for all next calls I've got an exception that file is read-only
in dest folder. How can I remove file attr read-only
to make image-copy works every time I call it?
推荐答案
你可以使用 gulp-chmod 处理文件的权限.
You can use gulp-chmod to handle permissions on your files.
因此,如果您想为所有人设置 可读
和 writable
图像,您可以使用以下内容:
So if you want to set your images readable
and writable
for everybody, you could go with something like:
var chmod = require('gulp-chmod');
gulp.task('copy-images', function() {
gulp.src(path_resource_images + '**/*.jpg')
.pipe(chmod(666))
.pipe(gulp.dest(path_app_images));
});
这篇关于Gulp - 处理目标文件的只读权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!