gulp-chown
Version:
Change owner of Vinyl files
82 lines (56 loc) • 1.55 kB
Markdown
> [Change owner](https://en.wikipedia.org/wiki/Chown) of [Vinyl](https://github.com/gulpjs/vinyl) files
```sh
npm install --save-dev gulp-chown
```
```js
import gulp from 'gulp';
import chown from 'gulp-chown';
export default () => (
gulp.src('src/app.js')
.pipe(chown('sindresorhus'))
.pipe(gulp.dest('dist'))
);
```
or
```js
import gulp from 'gulp';
import chown from 'gulp-chown';
export default () => (
gulp.src('src/app.js')
.pipe(chown(501))
.pipe(gulp.dest('dist'))
);
```
The arguments must be of the same type.
*Required*\
Type: `string | number`
The user name or [user id](https://en.wikipedia.org/wiki/User_identifier) to change ownership to.
Type: `string | number`
The group name or [group id](https://en.wikipedia.org/wiki/Group_identifier) to change ownership to.
Combine it with [gulp-filter](https://github.com/sindresorhus/gulp-filter) to only change ownership of a subset of the files.
```js
import gulp from 'gulp';
import chown from 'gulp-chown';
import gFilter from 'gulp-filter';
const filter = gFilter('src/vendor-*.js');
export default () => (
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'))
);
```
- [gulp-chmod](https://github.com/sindresorhus/gulp-chmod) - Change permissions of Vinyl files