Skip to content
This repository has been archived by the owner on Nov 16, 2019. It is now read-only.

Commit

Permalink
set-user: Create prefix if missing
Browse files Browse the repository at this point in the history
close #47
  • Loading branch information
isaacs committed Sep 17, 2014
1 parent 1f07a91 commit c8ccdc6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/set-user.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var Conf = require('../npmconf.js').Conf
var assert = require('assert')
var path = require('path')
var fs = require('fs')
var mkdirp = require('mkdirp')

function setUser (cb) {
var defaultConf = this.root
Expand All @@ -19,8 +20,11 @@ function setUser (cb) {
}

var prefix = path.resolve(this.get("prefix"))
fs.stat(prefix, function (er, st) {
defaultConf.user = st && st.uid
return cb(er)
mkdirp(prefix, function (er) {

This comment has been minimized.

Copy link
@othiym23

othiym23 Sep 17, 2014

Contributor

It's pretty weird to have npm's configuration creating a directory like this. It would be a lot less weird to do it in npm itself, if we could figure out how to make that work.

if (er) return cb(er)
fs.stat(prefix, function (er, st) {
defaultConf.user = st && st.uid
return cb(er)
})
})
}

1 comment on commit c8ccdc6

@samccone
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.