Initial commit
[yaffs-website] / node_modules / isexe / windows.js
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 }