sindresorhus / gulp-chown Goto Github PK
View Code? Open in Web Editor NEWChange owner of Vinyl files
License: MIT License
Change owner of Vinyl files
License: MIT License
While the plug-in does change the file.stat.uid that information is not used by gulp.dest so does not seem to have any effect on the file ownership on writing. At a minimum the example should be changed to reflect this although I am not sure how the plug-in would be used without gulp.dest support.
On the npm page, in the API section, you say "userId" twice instead of saying "userId" for the first one and "groupId" for the second.
It spawns a child process which is slow. The result should be cached for the lifetime of the process in case a user uses it multiple times.
Line 30 in 46a77e6
I'm fairly new to Node.js and Gulp so I surely must have misunderstood the whole thing, but please bear with me.
I applied the very example in the readme but files don't get chown'ed (I'm running gulp as root of course).
The problem seems to be that the finish
function doesn't have any side effects, since the file stat data is changed in memory but never persisted:
function finish() {
file.stat.uid = finalUid != null ? finalUid : file.stat.uid;
file.stat.gid = finalGid != null ? finalGid : file.stat.gid;
cb(null, file);
}
my dirty fix was adding this code:
@@ -1,5 +1,6 @@
'use strict';
var gutil = require('gulp-util');
+var fs = require('fs');
var through = require('through2');
var uidNumber = require('uid-number');
var defaultMode = 511 & (~process.umask()); // 511 = 0777
@@ -23,6 +24,17 @@ module.exports = function (user, group) {
function finish() {
file.stat.uid = finalUid != null ? finalUid : file.stat.uid;
file.stat.gid = finalGid != null ? finalGid : file.stat.gid;
+ if (finalUid && finalGid) {
+ fs.chown(file.path, finalUid, finalGid, function (err) {
+ if (err) {
+ cb(new gutil.PluginError('gulp-chown', err, {fileName: file.path}));
+ return;
+ }
+ cb(null, file);
+ });
+ return;
+ }
+
cb(null, file);
}
but it doesn't feel right...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.