我在源文件夹中设置了 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 - 处理目标文件的只读权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
Browserify,Babel 6,Gulp - 传播运算符上的意外令牌Browserify, Babel 6, Gulp - Unexpected token on spread operator(Browserify,Babel 6,Gulp - 传播运算符上的意外令牌)
是否可以将标志传递给 Gulp 以使其以不同的方式Is it possible to pass a flag to Gulp to have it run tasks in different ways?(是否可以将标志传递给 Gulp 以使其以不同的方式运行任务
为什么我们需要在全局和本地安装 gulp?Why do we need to install gulp globally and locally?(为什么我们需要在全局和本地安装 gulp?)
如何一个接一个地依次运行 Gulp 任务How to run Gulp tasks sequentially one after the other(如何一个接一个地依次运行 Gulp 任务)
由于 MIME 类型而未加载样式表Stylesheet not loaded because of MIME-type(由于 MIME 类型而未加载样式表)
打开 Javascript 文件时 Visual Studio 2015 崩溃Visual Studio 2015 crashes when opening Javascript files(打开 Javascript 文件时 Visual Studio 2015 崩溃)