{"action":"created","issue":{"url":"https://api.github.com/repos/sindresorhus/gulp-chown/issues/5","labels_url":"https://api.github.com/repos/sindresorhus/gulp-chown/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/sindresorhus/gulp-chown/issues/5/comments","events_url":"https://api.github.com/repos/sindresorhus/gulp-chown/issues/5/events","html_url":"https://github.com/sindresorhus/gulp-chown/issues/5","id":78157643,"number":5,"title":"Chown not actually altering files","user":{"login":"LexLythius","id":813204,"avatar_url":"https://avatars.githubusercontent.com/u/813204?v=3","gravatar_id":"","url":"https://api.github.com/users/LexLythius","html_url":"https://github.com/LexLythius","followers_url":"https://api.github.com/users/LexLythius/followers","following_url":"https://api.github.com/users/LexLythius/following{/other_user}","gists_url":"https://api.github.com/users/LexLythius/gists{/gist_id}","starred_url":"https://api.github.com/users/LexLythius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LexLythius/subscriptions","organizations_url":"https://api.github.com/users/LexLythius/orgs","repos_url":"https://api.github.com/users/LexLythius/repos","events_url":"https://api.github.com/users/LexLythius/events{/privacy}","received_events_url":"https://api.github.com/users/LexLythius/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-05-19T16:25:56Z","updated_at":"2015-06-30T21:41:17Z","closed_at":null,"body":"I'm fairly new to Node.js and Gulp so I surely must have misunderstood the whole thing, but please bear with me.\r\n\r\nI applied the very example in the readme but files don't get chown'ed (I'm running gulp as root of course).\r\n\r\nThe 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:\r\n````javascript\r\nfunction finish() {\r\n\tfile.stat.uid = finalUid != null ? finalUid : file.stat.uid;\r\n\tfile.stat.gid = finalGid != null ? finalGid : file.stat.gid;\r\n\tcb(null, file);\r\n}\r\n````\r\nmy dirty fix was adding this code:\r\n````diff\r\n@@ -1,5 +1,6 @@\r\n 'use strict';\r\n var gutil = require('gulp-util');\r\n+var fs = require('fs');\r\n var through = require('through2');\r\n var uidNumber = require('uid-number');\r\n var defaultMode = 511 & (~process.umask()); // 511 = 0777\r\n@@ -23,6 +24,17 @@ module.exports = function (user, group) {\r\n \t\tfunction finish() {\r\n \t\t\tfile.stat.uid = finalUid != null ? finalUid : file.stat.uid;\r\n \t\t\tfile.stat.gid = finalGid != null ? finalGid : file.stat.gid;\r\n+\t\t\tif (finalUid && finalGid) {\r\n+\t\t\t\tfs.chown(file.path, finalUid, finalGid, function (err) {\r\n+\t\t\t\t\tif (err) {\r\n+\t\t\t\t\t\tcb(new gutil.PluginError('gulp-chown', err, {fileName: file.path}));\r\n+\t\t\t\t\t\treturn;\r\n+\t\t\t\t\t}\r\n+\t\t\t\t\tcb(null, file);\r\n+\t\t\t\t});\r\n+\t\t\t\treturn;\r\n+\t\t\t}\r\n+\r\n \t\t\tcb(null, file);\r\n \t\t}\r\n````\r\nbut it doesn't feel right...\r\n"},"comment":{"url":"https://api.github.com/repos/sindresorhus/gulp-chown/issues/comments/117353475","html_url":"https://github.com/sindresorhus/gulp-chown/issues/5#issuecomment-117353475","issue_url":"https://api.github.com/repos/sindresorhus/gulp-chown/issues/5","id":117353475,"user":{"login":"c0d3rman","id":5343762,"avatar_url":"https://avatars.githubusercontent.com/u/5343762?v=3","gravatar_id":"","url":"https://api.github.com/users/c0d3rman","html_url":"https://github.com/c0d3rman","followers_url":"https://api.github.com/users/c0d3rman/followers","following_url":"https://api.github.com/users/c0d3rman/following{/other_user}","gists_url":"https://api.github.com/users/c0d3rman/gists{/gist_id}","starred_url":"https://api.github.com/users/c0d3rman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c0d3rman/subscriptions","organizations_url":"https://api.github.com/users/c0d3rman/orgs","repos_url":"https://api.github.com/users/c0d3rman/repos","events_url":"https://api.github.com/users/c0d3rman/events{/privacy}","received_events_url":"https://api.github.com/users/c0d3rman/received_events","type":"User","site_admin":false},"created_at":"2015-06-30T21:41:17Z","updated_at":"2015-06-30T21:41:17Z","body":"OK - a crude fix:\r\nAdding `fs.chown(writePath, file.stat.uid, file.stat.gid, function(){});` at the end of the `fs.stat` call in the `written` function in `vinyl-fs/lib/dest/writeContents/index.js` (line 31 for me) fixes it, but only if you don't also use `gulp-chmod`.\r\nThis obviously is a terrible fix (no error handling, breaks `gulp-chmod`, etc.) but it's the beginning of a solution.\r\nThe main problem now is that the `done` (or `complete`, depends on `vinyl-fs` version) callback can't be used by both `fs.chmos` and `fs.chown`."}}