"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/npm/lib/config/set-user.js" (7 Feb 2017, 749 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 module.exports = setUser
    2 
    3 var assert = require('assert')
    4 var path = require('path')
    5 var fs = require('fs')
    6 var mkdirp = require('mkdirp')
    7 
    8 function setUser (cb) {
    9   var defaultConf = this.root
   10   assert(defaultConf !== Object.prototype)
   11 
   12   // If global, leave it as-is.
   13   // If not global, then set the user to the owner of the prefix folder.
   14   // Just set the default, so it can be overridden.
   15   if (this.get('global')) return cb()
   16   if (process.env.SUDO_UID) {
   17     defaultConf.user = +(process.env.SUDO_UID)
   18     return cb()
   19   }
   20 
   21   var prefix = path.resolve(this.get('prefix'))
   22   mkdirp(prefix, function (er) {
   23     if (er) return cb(er)
   24     fs.stat(prefix, function (er, st) {
   25       defaultConf.user = st && st.uid
   26       return cb(er)
   27     })
   28   })
   29 }