Server IP : 127.0.0.2 / Your IP : 18.216.60.85 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/share/npm/lib/install/action/ |
Upload File : |
'use strict' var path = require('path') var fs = require('graceful-fs') var rimraf = require('rimraf') var asyncMap = require('slide').asyncMap var mkdirp = require('mkdirp') var npm = require('../../npm.js') var andIgnoreErrors = require('../and-ignore-errors.js') var rename = require('../../utils/rename.js') // This is weird because we want to remove the module but not it's node_modules folder // allowing for this allows us to not worry about the order of operations module.exports = function (top, buildpath, pkg, log, next) { log.silly('remove', pkg.path) if (pkg.target) { removeLink(pkg, next) } else { removeDir(pkg, log, next) } } function removeLink (pkg, next) { npm.commands.unbuild(pkg.path, true, next) } function removeDir (pkg, log, next) { var modpath = path.join(path.dirname(pkg.path), '.' + path.basename(pkg.path) + '.MODULES') rename(path.join(pkg.path, 'node_modules'), modpath, unbuildPackage) function unbuildPackage (renameEr) { npm.commands.unbuild(pkg.path, true, function () { rimraf(pkg.path, renameEr ? andRemoveEmptyParents(pkg.path) : moveModulesBack) }) } function andRemoveEmptyParents (path) { return function (er) { if (er) return next(er) removeEmptyParents(pkg.path) } } function moveModulesBack () { fs.readdir(modpath, makeTarget) } function makeTarget (readdirEr, files) { if (readdirEr) return cleanup() if (!files.length) return cleanup() mkdirp(path.join(pkg.path, 'node_modules'), function (mkdirEr) { moveModules(mkdirEr, files) }) } function moveModules (mkdirEr, files) { if (mkdirEr) return next(mkdirEr) asyncMap(files, function (file, done) { var from = path.join(modpath, file) var to = path.join(pkg.path, 'node_modules', file) // we ignore errors here, because they can legitimately happen, for instance, // bundled modules will be in both node_modules folders rename(from, to, andIgnoreErrors(done)) }, cleanup) } function cleanup () { rimraf(modpath, afterCleanup) } function afterCleanup (rimrafEr) { if (rimrafEr) log.warn('remove', rimrafEr) removeEmptyParents(path.resolve(pkg.path, '..')) } function removeEmptyParents (pkgdir) { fs.rmdir(pkgdir, function (er) { // FIXME: Make sure windows does what we want here if (er && er.code !== 'ENOENT') return next() removeEmptyParents(path.resolve(pkgdir, '..')) }) } }