Change permissions of Vinyl files
$ npm install --save-dev gulp-chown
var gulp = require('gulp');
var chown = require('gulp-chown');
gulp.task('default', function () {
return gulp.src('src/app.js')
.pipe(chown('sindresorhus'))
.pipe(gulp.dest('dist'));
});
or
var gulp = require('gulp');
var chown = require('gulp-chown');
gulp.task('default', function () {
return gulp.src('src/app.js')
.pipe(chown(501))
.pipe(gulp.dest('dist'));
});
Arguments must be of the same type.
Required
Type: string
, number
The user name or user id to change ownership to.
Type: string
, number
The group name or group id to change ownership to.
Combine it with gulp-filter to only change ownership of a subset of the files.
var gulp = require('gulp');
var gFilter = require('gulp-filter');
var chown = require('gulp-chown');
var filter = gFilter('src/vendor-*.js');
gulp.task('default', function () {
return gulp.src('src/*.js')
// filter a subset of the files
.pipe(filter)
// change ownership of them
.pipe(chown('sindresorhus'))
// bring back the previously filtered out files
.pipe(filter.restore())
.pipe(gulp.dest('dist'));
});
MIT © Sindre Sorhus