Server IP : 127.0.0.2 / Your IP : 3.148.206.183 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/lib/nodejs/npm/lib/config/ |
Upload File : |
// try to find the most reasonable prefix to use module.exports = findPrefix var fs = require('fs') var path = require('path') function findPrefix (p, cb_) { function cb (er, p) { process.nextTick(function () { cb_(er, p) }) } p = path.resolve(p) // if there's no node_modules folder, then // walk up until we hopefully find one. // if none anywhere, then use cwd. var walkedUp = false while (path.basename(p) === 'node_modules') { p = path.dirname(p) walkedUp = true } if (walkedUp) return cb(null, p) findPrefix_(p, p, cb) } function findPrefix_ (p, original, cb) { if (p === '/' || (process.platform === 'win32' && p.match(/^[a-zA-Z]:(\\|\/)?$/))) { return cb(null, original) } fs.readdir(p, function (er, files) { // an error right away is a bad sign. // unless the prefix was simply a non // existent directory. if (er && p === original) { if (er.code === 'ENOENT') return cb(null, original) return cb(er) } // walked up too high or something. if (er) return cb(null, original) if (files.indexOf('node_modules') !== -1 || files.indexOf('package.json') !== -1) { return cb(null, p) } var d = path.dirname(p) if (d === p) return cb(null, original) return findPrefix_(d, original, cb) }) }