"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/npm/lib/install/read-shrinkwrap.js" (8 Mar 2017, 884 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 path = require('path')
    3 var fs = require('graceful-fs')
    4 var iferr = require('iferr')
    5 var inflateShrinkwrap = require('./inflate-shrinkwrap.js')
    6 var parseJSON = require('../utils/parse-json.js')
    7 
    8 var readShrinkwrap = module.exports = function (child, next) {
    9   fs.readFile(path.join(child.path, 'npm-shrinkwrap.json'), function (er, data) {
   10     if (er) {
   11       child.package._shrinkwrap = null
   12       return next()
   13     }
   14     try {
   15       child.package._shrinkwrap = parseJSON(data)
   16     } catch (ex) {
   17       child.package._shrinkwrap = null
   18       return next(ex)
   19     }
   20     return next()
   21   })
   22 }
   23 
   24 module.exports.andInflate = function (child, next) {
   25   readShrinkwrap(child, iferr(next, function () {
   26     if (child.package._shrinkwrap) {
   27       return inflateShrinkwrap(child, child.package._shrinkwrap.dependencies || {}, next)
   28     } else {
   29       return next()
   30     }
   31   }))
   32 }