Server IP : 127.0.0.2 / Your IP : 13.58.157.160 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/ |
Upload File : |
'use strict' var path = require('path') var validate = require('aproba') var chain = require('slide').chain var asyncMap = require('slide').asyncMap var log = require('npmlog') var andFinishTracker = require('./and-finish-tracker.js') var andAddParentToErrors = require('./and-add-parent-to-errors.js') var failedDependency = require('./deps.js').failedDependency var packageId = require('../utils/package-id.js') var moduleName = require('../utils/module-name.js') var buildPath = require('./build-path.js') var actions = {} actions.fetch = require('./action/fetch.js') actions.extract = require('./action/extract.js') actions.build = require('./action/build.js') actions.test = require('./action/test.js') actions.preinstall = require('./action/preinstall.js') actions.install = require('./action/install.js') actions.postinstall = require('./action/postinstall.js') actions.prepublish = require('./action/prepublish.js') actions.finalize = require('./action/finalize.js') actions.remove = require('./action/remove.js') actions.move = require('./action/move.js') actions['update-linked'] = require('./action/update-linked.js') actions['global-install'] = require('./action/global-install.js') actions['global-link'] = require('./action/global-link.js') // FIXME: We wrap actions like three ways to sunday here. // Rewrite this to only work one way. Object.keys(actions).forEach(function (actionName) { var action = actions[actionName] actions[actionName] = function (top, buildpath, pkg, log, next) { validate('SSOOF', arguments) // refuse to run actions for failed packages if (pkg.failed) return next() if (action.rollback) { if (!pkg.rollback) pkg.rollback = [] pkg.rollback.unshift(action.rollback) } if (action.commit) { if (!pkg.commit) pkg.commit = [] pkg.commit.push(action.commit) } return action(top, buildpath, pkg, log, andFinishTracker(log, andAddParentToErrors(pkg.parent, andHandleOptionalDepErrors(pkg, next)))) } }) function markAsFailed (pkg) { pkg.failed = true pkg.requires.forEach(function (req) { req.requiredBy = req.requiredBy.filter(function (reqReqBy) { return reqReqBy !== pkg }) if (req.requiredBy.length === 0 && !req.userRequired && !req.existing) { markAsFailed(req) } }) } function andHandleOptionalDepErrors (pkg, next) { return function (er) { if (!er) return next.apply(null, arguments) markAsFailed(pkg) var anyFatal = pkg.userRequired || !pkg.parent for (var ii = 0; ii < pkg.requiredBy.length; ++ii) { var parent = pkg.requiredBy[ii] var isFatal = failedDependency(parent, pkg) if (isFatal) anyFatal = true } if (anyFatal) return next.apply(null, arguments) log.warn('install:' + packageId(pkg), er.message) log.verbose('install:' + packageId(pkg), er.stack) next() } } function prepareAction (staging, log) { validate('SO', arguments) return function (action) { validate('SO', action) var cmd = action[0] var pkg = action[1] if (!actions[cmd]) throw new Error('Unknown decomposed command "' + cmd + '" (is it new?)') var top = path.resolve(staging, '../..') var buildpath = buildPath(staging, pkg) return [actions[cmd], top, buildpath, pkg, log.newGroup(cmd + ':' + moduleName(pkg))] } } exports.actions = actions function execAction (todo, done) { validate('AF', arguments) var cmd = todo.shift() todo.push(done) cmd.apply(null, todo) } exports.doOne = function (cmd, staging, pkg, log, next) { validate('SSOOF', arguments) execAction(prepareAction(staging, log)([cmd, pkg]), next) } exports.doSerial = function (type, staging, actionsToRun, log, next) { validate('SSAOF', arguments) actionsToRun = actionsToRun .filter(function (value) { return value[0] === type }) log.silly('doSerial', '%s %d', type, actionsToRun.length) chain(actionsToRun.map(prepareAction(staging, log)), andFinishTracker(log, next)) } exports.doReverseSerial = function (type, staging, actionsToRun, log, next) { validate('SSAOF', arguments) actionsToRun = actionsToRun .filter(function (value) { return value[0] === type }) .reverse() log.silly('doReverseSerial', '%s %d', type, actionsToRun.length) chain(actionsToRun.map(prepareAction(staging, log)), andFinishTracker(log, next)) } exports.doParallel = function (type, staging, actionsToRun, log, next) { validate('SSAOF', arguments) actionsToRun = actionsToRun.filter(function (value) { return value[0] === type }) log.silly('doParallel', type + ' ' + actionsToRun.length) asyncMap(actionsToRun.map(prepareAction(staging, log)), execAction, andFinishTracker(log, next)) }