"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/npm/lib/install/decompose-actions.js" (8 Mar 2017, 1405 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 'use strict'
    2 var validate = require('aproba')
    3 var asyncMap = require('slide').asyncMap
    4 var npm = require('../npm.js')
    5 
    6 module.exports = function (differences, decomposed, next) {
    7   validate('AAF', arguments)
    8   asyncMap(differences, function (action, done) {
    9     var cmd = action[0]
   10     var pkg = action[1]
   11     switch (cmd) {
   12       case 'add':
   13       case 'update':
   14         addSteps(decomposed, pkg, done)
   15         break
   16       case 'move':
   17         moveSteps(decomposed, pkg, done)
   18         break
   19       case 'remove':
   20       case 'update-linked':
   21       default:
   22         defaultSteps(decomposed, cmd, pkg, done)
   23     }
   24   }, next)
   25 }
   26 
   27 function addSteps (decomposed, pkg, done) {
   28   if (!pkg.fromBundle) {
   29     decomposed.push(['fetch', pkg])
   30     decomposed.push(['extract', pkg])
   31     decomposed.push(['test', pkg])
   32   }
   33   if (!pkg.fromBundle || npm.config.get('rebuild-bundle')) {
   34     decomposed.push(['preinstall', pkg])
   35     decomposed.push(['build', pkg])
   36     decomposed.push(['install', pkg])
   37     decomposed.push(['postinstall', pkg])
   38   }
   39   decomposed.push(['finalize', pkg])
   40   done()
   41 }
   42 
   43 function moveSteps (decomposed, pkg, done) {
   44   decomposed.push(['move', pkg])
   45   decomposed.push(['build', pkg])
   46   decomposed.push(['install', pkg])
   47   decomposed.push(['postinstall', pkg])
   48   decomposed.push(['test', pkg])
   49   done()
   50 }
   51 
   52 function defaultSteps (decomposed, cmd, pkg, done) {
   53   decomposed.push([cmd, pkg])
   54   done()
   55 }