問題描述
我在源文件夾中設(shè)置了 read-only
屬性的圖像文件.在大多數(shù)情況下,我需要在 gulpfile.js 中多次將它們復(fù)制到目標(biāo)文件夾.
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.
我正在嘗試像這樣復(fù)制 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));
});
當(dāng) dest 文件夾為空時(shí),它會(huì)工作一次.但是對(duì)于接下來的所有調(diào)用,我都有一個(gè)例外,即文件在 dest 文件夾中是 read-only
.如何刪除文件屬性 read-only
以使 image-copy 每次調(diào)用時(shí)都能正常工作?
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 處理文件的權(quán)限.
You can use gulp-chmod to handle permissions on your files.
因此,如果您想為所有人設(shè)置 可讀
和 writable
圖像,您可以使用以下內(nèi)容:
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));
});
這篇關(guān)于Gulp - 處理目標(biāo)文件的只讀權(quán)限?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!