Socket
Socket
Sign inDemoInstall

isexe

Package Overview
Dependencies
0
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.2 to 2.0.0

2

index.js

@@ -5,4 +5,2 @@ var fs = require('fs')

core = require('./windows.js')
} else if (typeof fs.access === 'function') {
core = require('./access.js')
} else {

@@ -9,0 +7,0 @@ core = require('./mode.js')

10

mode.js

@@ -7,4 +7,4 @@ module.exports = isexe

function isexe (path, options, cb) {
fs.stat(path, function (er, st) {
cb(er, er ? false : checkMode(st, options))
fs.stat(path, function (er, stat) {
cb(er, er ? false : checkStat(stat, options))
})

@@ -14,5 +14,9 @@ }

function sync (path, options) {
return checkMode(fs.statSync(path), options)
return checkStat(fs.statSync(path), options)
}
function checkStat (stat, options) {
return stat.isFile() && checkMode(stat, options)
}
function checkMode (stat, options) {

@@ -19,0 +23,0 @@ var mod = stat.mode

{
"name": "isexe",
"version": "1.1.2",
"version": "2.0.0",
"description": "Minimal module to check if a file is executable.",

@@ -12,6 +12,9 @@ "main": "index.js",

"rimraf": "^2.5.0",
"tap": "^5.1.2"
"tap": "^10.3.0"
},
"scripts": {
"test": "tap test/*.js --branches=100 --statements=100 --functions=100 --lines=100"
"test": "tap test/*.js --100",
"preversion": "npm test",
"postversion": "npm publish",
"postpublish": "git push origin --all; git push origin --tags"
},

@@ -18,0 +21,0 @@ "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",

# isexe
Minimal module to check if a file is executable.
Minimal module to check if a file is executable, and a normal file.
Uses `fs.access` if available, and tests against the `PATHEXT`
environment variable on Windows.
Uses `fs.stat` and tests against the `PATHEXT` environment variable on
Windows.

@@ -37,4 +37,4 @@ ## USAGE

Will raise whatever errors may be raised by `fs.access` or `fs.stat`,
unless `options.ignoreErrors` is set to true.
Will raise whatever errors may be raised by `fs.stat`, unless
`options.ignoreErrors` is set to true.

@@ -49,5 +49,5 @@ ### `isexe.sync(path, [options])`

don't raise them.
* `uid` Number to use as the user id when using the `mode` approach.
* `gid` Number to use as the group id when using the `mode` approach.
* `uid` Number to use as the user id
* `gid` Number to use as the group id
* `pathExt` List of path extensions to use instead of `PATHEXT`
environment variable on Windows.

@@ -210,3 +210,13 @@ var t = require('tap')

t.test('directory is not executable', function (t) {
isexe(__dirname, options, function (er, is) {
if (er) {
throw er
}
t.notOk(is)
t.end()
})
})
t.end()
}

@@ -27,5 +27,12 @@ module.exports = isexe

function checkStat (stat, path, options) {
if (!stat.isSymbolicLink() && !stat.isFile()) {
return false
}
return checkPathExt(path, options)
}
function isexe (path, options, cb) {
fs.stat(path, function (er, st) {
cb(er, er ? false : checkPathExt(path, options))
fs.stat(path, function (er, stat) {
cb(er, er ? false : checkStat(stat, path, options))
})

@@ -35,4 +42,3 @@ }

function sync (path, options) {
fs.statSync(path)
return checkPathExt(path, options)
return checkStat(fs.statSync(path), path, options)
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc