|
|
8 năm trước cách đây | |
|---|---|---|
| .. | ||
| index.js | 8 năm trước cách đây | |
| package.json | 8 năm trước cách đây | |
| readme.md | 8 năm trước cách đây | |
Change permissions of Vinyl files
$ npm install --save-dev gulp-chmod
const gulp = require('gulp');
const chmod = require('gulp-chmod');
gulp.task('default', () => {
return gulp.src('src/app.js')
.pipe(chmod(755))
.pipe(gulp.dest('dist'));
});
or
const gulp = require('gulp');
const chmod = require('gulp-chmod');
gulp.task('default', () => {
return gulp.src('src/app.js')
.pipe(chmod({
owner: {
read: true,
write: true,
execute: true
},
group: {
execute: true
},
others: {
execute: true
}
}))
.pipe(gulp.dest('dist'));
});
Type: number, object
Can either be a chmod mode number or an object with the individual permissions specified.
Values depends on the current file, but these are the possible keys:
{
owner: {
read: true,
write: true,
execute: true
},
group: {
read: true,
write: true,
execute: true
},
others: {
read: true,
write: true,
execute: true
}
}
When read, write and execute are same, you can simplify the object:
{
read: true
}
Combine it with gulp-filter to only change permissions on a subset of the files.
const gulp = require('gulp');
const gFilter = require('gulp-filter');
const chmod = require('gulp-chmod');
const filter = gFilter('src/cli.js', {restore: true});
gulp.task('default', () => {
return gulp.src('src/*.js')
// filter a subset of the files
.pipe(filter)
// make them executable
.pipe(chmod(755))
// bring back the previously filtered out files
.pipe(filter.restore)
.pipe(gulp.dest('dist'));
});
MIT © Sindre Sorhus