"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/npm/lib/install/exists.js" (8 Mar 2017, 775 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 fs = require('fs')
    3 var inflight = require('inflight')
    4 var accessError = require('./access-error.js')
    5 var isFsAccessAvailable = require('./is-fs-access-available.js')
    6 
    7 if (isFsAccessAvailable) {
    8   module.exports = fsAccessImplementation
    9 } else {
   10   module.exports = fsStatImplementation
   11 }
   12 
   13 // exposed only for testing purposes
   14 module.exports.fsAccessImplementation = fsAccessImplementation
   15 module.exports.fsStatImplementation = fsStatImplementation
   16 
   17 function fsAccessImplementation (dir, done) {
   18   done = inflight('exists:' + dir, done)
   19   if (!done) return
   20   fs.access(dir, fs.F_OK, done)
   21 }
   22 
   23 function fsStatImplementation (dir, done) {
   24   done = inflight('exists:' + dir, done)
   25   if (!done) return
   26   fs.stat(dir, function (er) { done(accessError(dir, er)) })
   27 }