Server IP : 127.0.0.2 / Your IP : 3.148.252.90 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 fs = require('graceful-fs') var path = require('path') var chain = require('slide').chain var iferr = require('iferr') var rimraf = require('rimraf') var mkdirp = require('mkdirp') var rmStuff = require('../../unbuild.js').rmStuff var lifecycle = require('../../utils/lifecycle.js') var updatePackageJson = require('../update-package-json.js') var rename = require('../../utils/rename.js') /* Move a module from one point in the node_modules tree to another. Do not disturb either the source or target location's node_modules folders. */ module.exports = function (top, buildpath, pkg, log, next) { log.silly('move', pkg.fromPath, pkg.path) chain([ [lifecycle, pkg.package, 'preuninstall', pkg.fromPath, false, true], [lifecycle, pkg.package, 'uninstall', pkg.fromPath, false, true], [rmStuff, pkg.package, pkg.fromPath], [lifecycle, pkg.package, 'postuninstall', pkg.fromPath, false, true], [moveModuleOnly, pkg.fromPath, pkg.path, log], [lifecycle, pkg.package, 'preinstall', pkg.path, false, true], [removeEmptyParents, path.resolve(pkg.fromPath, '..')], [updatePackageJson, pkg, pkg.path] ], next) } function removeEmptyParents (pkgdir, next) { 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, '..'), next) }) } function moveModuleOnly (from, to, log, done) { var fromModules = path.join(from, 'node_modules') var tempFromModules = from + '.node_modules' var toModules = path.join(to, 'node_modules') var tempToModules = to + '.node_modules' log.silly('move', 'move existing destination node_modules away', toModules) rename(toModules, tempToModules, removeDestination(done)) function removeDestination (next) { return function (er) { log.silly('move', 'remove existing destination', to) if (er) { rimraf(to, iferr(next, makeDestination(next))) } else { rimraf(to, iferr(next, makeDestination(iferr(next, moveToModulesBack(next))))) } } } function moveToModulesBack (next) { return function () { log.silly('move', 'move existing destination node_modules back', toModules) rename(tempToModules, toModules, iferr(done, next)) } } function makeDestination (next) { return function () { log.silly('move', 'make sure destination parent exists', path.resolve(to, '..')) mkdirp(path.resolve(to, '..'), iferr(done, moveNodeModules(next))) } } function moveNodeModules (next) { return function () { log.silly('move', 'move source node_modules away', fromModules) rename(fromModules, tempFromModules, iferr(doMove(next), doMove(moveNodeModulesBack(next)))) } } function doMove (next) { return function () { log.silly('move', 'move module dir to final dest', from, to) rename(from, to, iferr(done, next)) } } function moveNodeModulesBack (next) { return function () { mkdirp(from, iferr(done, function () { log.silly('move', 'put source node_modules back', fromModules) rename(tempFromModules, fromModules, iferr(done, next)) })) } } }