Gulp - Handle read-only permissions for dest files?(Gulp - 处理目标文件的只读权限?)
问题描述
我在源文件夹中设置了 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 - 处理目标文件的只读权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Gulp - 处理目标文件的只读权限?


基础教程推荐
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01