"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/isexe/windows.js" (8 Mar 2017, 735 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 = isexe
    2 isexe.sync = sync
    3 
    4 var fs = require('fs')
    5 
    6 function checkPathExt (path, options) {
    7   var pathext = options.pathExt !== undefined ?
    8     options.pathExt : process.env.PATHEXT
    9 
   10   if (!pathext) {
   11     return true
   12   }
   13 
   14   pathext = pathext.split(';')
   15   if (pathext.indexOf('') !== -1) {
   16     return true
   17   }
   18   for (var i = 0; i < pathext.length; i++) {
   19     var p = pathext[i].toLowerCase()
   20     if (p && path.substr(-p.length).toLowerCase() === p) {
   21       return true
   22     }
   23   }
   24   return false
   25 }
   26 
   27 function isexe (path, options, cb) {
   28   fs.stat(path, function (er, st) {
   29     cb(er, er ? false : checkPathExt(path, options))
   30   })
   31 }
   32 
   33 function sync (path, options) {
   34   fs.statSync(path)
   35   return checkPathExt(path, options)
   36 }