Gulp - 处理dest文件的只读权限? [英] Gulp - Handle read-only permissions for dest files?

查看:136
本文介绍了Gulp - 处理dest文件的只读权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在源文件夹中设置了只读属性集的图像文件。我需要在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文件夹中有一个异常,该文件是只读。每次我打电话时,如何删除文件attr 只读以使 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.

因此,如果您想设置图像可读可写入给所有人,你可以使用类似的方式:

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 - 处理dest文件的只读权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆