"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/npm/lib/config/load-cafile.js" (11 Apr 2017, 682 Bytes) of package /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 module.exports = loadCAFile
    2 
    3 var fs = require('fs')
    4 
    5 function loadCAFile (cafilePath, cb) {
    6   if (!cafilePath) return process.nextTick(cb)
    7 
    8   fs.readFile(cafilePath, 'utf8', afterCARead.bind(this))
    9 
   10   function afterCARead (er, cadata) {
   11     if (er) {
   12       // previous cafile no longer exists, so just continue on gracefully
   13       if (er.code === 'ENOENT') return cb()
   14       return cb(er)
   15     }
   16 
   17     var delim = '-----END CERTIFICATE-----'
   18     var output
   19 
   20     output = cadata
   21       .split(delim)
   22       .filter(function (xs) {
   23         return !!xs.trim()
   24       })
   25       .map(function (xs) {
   26         return xs.trimLeft() + delim
   27       })
   28 
   29     this.set('ca', output)
   30     cb(null)
   31   }
   32 }