Skip to content

Commit

Permalink
set permissions after git clone, fix npm#3117
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaakko Manninen committed Mar 4, 2013
1 parent a3d9965 commit 886e2aa
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion lib/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,34 @@ function addRemoteGit (u, parsed, name, cb_) {

p = path.join(npm.config.get("cache"), "_git-remotes", v)

checkGitDir(p, u, co, origUrl, cb)
checkGitDir(p, u, co, origUrl, function(er, data) {
chmodr(p, npm.modes.file, function(erChmod) {
if (er) return cb(er, data)
return cb(erChmod, data)
})
})
})
}

function chmodr(p, mode, cb) {
fs.chmod(p, mode, function(er) {
if (er) return cb(er)
fs.readdir(p, function(er, kids) {
if (er) return cb(er)
function next(er) {
if (er) return cb(er)
var kid = kids.shift()
if (!kid) return cb()
var kidPath = path.join(p, kid)
fs.stat(kidPath, function(er, stat) {
if (er) return cb(er)
if (stat.isDirectory())
return chmodr(kidPath, mode, next)
fs.chmod(kidPath, mode, next)
})
}
next()
})
})
}

Expand Down

0 comments on commit 886e2aa

Please sign in to comment.