Change permissions of Vinyl files
$ npm install --save-dev gulp-chflags
var gulp = require('gulp');
var chmod = require('gulp-chflags');
gulp.task('default', function () {
return gulp.src('src/app.js')
.pipe(chflags(23))
.pipe(gulp.dest('dist'));
});or
var gulp = require('gulp');
var chmod = require('gulp-chflags');
gulp.task('default', function () {
return gulp.src('src/app.js')
.pipe(chflags([
'uchg',
'uunlnk'
]))
.pipe(gulp.dest('dist'));
});Type: number, array
Can either be a chflags octal number or an array with the individual flags specified.
Values depends on the current file, but these are the possible keys:
{
'hidden',
'opaque',
'nodump',
'uappnd',
'uappend',
'uchg',
'uchange',
'uimmutable',
'uunlnk',
'uunlink',
'arch',
'archived',
'sappnd',
'sappend',
'schg',
'schange',
'simmutable',
'sunlnk',
'sunlink'
}Putting the letters no before an option causes the flag to be turned off. For example:
'uchg': Means the file cannot be changed'nouchg': Means the file can be changed (immutable bit cleared)'hidden': Will set the hidden flag'nohidden': Will remove the hidden flag
Combine it with gulp-filter to only change permissions on a subset of the files.
var gulp = require('gulp');
var gFilter = require('gulp-filter');
var chmod = require('gulp-chmod');
var filter = gFilter('src/cli.js');
gulp.task('default', function () {
return gulp.src('src/*.js')
// filter a subset of the files
.pipe(filter)
// make them immutable
.pipe(chflags(['uchg']))
// bring back the previously filtered out files
.pipe(filter.restore())
.pipe(gulp.dest('dist'));
});Credit goes to Sindre Sorhus for providing an excellent template for this project by means of gulp-chmod and gulp-chown.