Change owner of Vinyl files
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.editorconfig tweaks Sep 2, 2014
.gitattributes tweaks Sep 2, 2014
.gitignore init Mar 7, 2014
.jshintrc tweaks Sep 2, 2014
.travis.yml fix tests Feb 8, 2015
index.js Close #7 PR: Cache UID/GID per user/group. May 27, 2015
license tweaks Sep 2, 2014
package.json 1.1.0 Oct 16, 2015
readme.md readme tweaks Oct 16, 2015
test.js fix tests Feb 8, 2015

readme.md

gulp-chown Build Status

Change owner of Vinyl files

Install

$ npm install --save-dev gulp-chown

Usage

const gulp = require('gulp');
const chown = require('gulp-chown');

gulp.task('default', () => {
    return gulp.src('src/app.js')
        .pipe(chown('sindresorhus'))
        .pipe(gulp.dest('dist'));
});

or

const gulp = require('gulp');
const chown = require('gulp-chown');

gulp.task('default', () => {
    return gulp.src('src/app.js')
        .pipe(chown(501))
        .pipe(gulp.dest('dist'));
});

API

chown(userId, groupId)

Arguments must be of the same type.

userId

Required
Type: string, number

The user name or user id to change ownership to.

groupId

Type: string, number

The group name or group id to change ownership to.

Tip

Combine it with gulp-filter to only change ownership of a subset of the files.

const gulp = require('gulp');
const gFilter = require('gulp-filter');
const chown = require('gulp-chown');

const filter = gFilter('src/vendor-*.js');

gulp.task('default', () => {
    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'));
});

Related

License

MIT © Sindre Sorhus