問題描述
我在源文件夾中設置了 read-only
屬性的圖像文件.在大多數(shù)情況下,我需要在 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 - 處理目標文件的只讀權限?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!