Gulp - 处理目标文件的只读权限?

Gulp - Handle read-only permissions for dest files?(Gulp - 处理目标文件的只读权限?)
本文介绍了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 - 处理目标文件的只读权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

How do I can get a text of all the cells of the table using testcafe(如何使用 testcafe 获取表格中所有单元格的文本)
node_modules is not recognized as an internal or external command(node_modules 未被识别为内部或外部命令)
How can I create conditional test cases using Protractor?(如何使用 Protractor 创建条件测试用例?)
PhantomJS and clicking a form button(PhantomJS 并单击表单按钮)
Clicking #39;OK#39; on alert or confirm dialog through jquery/javascript?(在警报上单击“确定或通过 jquery/javascript 确认对话框?)
QunitJS-Tests don#39;t start: PhantomJS timed out, possibly due to a missing QUnit start() call(QunitJS-Tests 不启动:PhantomJS 超时,可能是由于缺少 QUnit start() 调用)