Gulp - Handle read-only permissions for dest files?

前端 未结 3 1559
半阙折子戏
半阙折子戏 2021-01-08 00:37

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.

相关标签:
3条回答
  • 2021-01-08 00:39

    By passing options attribute. Set mode value to specify permission for any folders that need to be created as output.

    gulp.dest("destination-path-here", {"mode": "0777"})
    

    cheers :-)

    0 讨论(0)
  • 2021-01-08 00:42

    rimraf can be used to avoid issues with TFS permissions (by deleting destination files before copying files)

    var rimraf = require("rimraf");
    gulp.task("images_clean", function (cb) {
        rimraf(imagesDest, cb);
    });
    
    0 讨论(0)
  • 2021-01-08 00:59

    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));
    });
    
    0 讨论(0)
提交回复
热议问题