Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gulp - Handle read-only permissions for dest files?

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.

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));
});

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?

like image 216
SeO Avatar asked Oct 24 '14 02:10

SeO


2 Answers

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));
});
like image 143
Preview Avatar answered Nov 16 '22 20:11

Preview


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 :-)

like image 10
Mohan Avatar answered Nov 16 '22 20:11

Mohan