[Pkg-javascript-commits] [node-isexe] 01/05: New upstream version 2.0.0

Bastien Roucariès rouca at moszumanska.debian.org
Fri Aug 25 15:31:04 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-isexe.

commit 989f6dc9ab996207641ff3124ed912a94ae96279
Author: Bastien ROUCARIÈS <roucaries.bastien at gmail.com>
Date:   Fri Aug 25 16:22:42 2017 +0200

    New upstream version 2.0.0
---
 README.md     | 14 +++++++-------
 access.js     | 15 ---------------
 index.js      |  2 --
 mode.js       | 10 +++++++---
 package.json  |  9 ++++++---
 test/basic.js | 10 ++++++++++
 windows.js    | 14 ++++++++++----
 7 files changed, 40 insertions(+), 34 deletions(-)

diff --git a/README.md b/README.md
index 30995ad..35769e8 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,9 @@
 # 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.
 
 ## USAGE
 
@@ -34,8 +34,8 @@ var isExe = isexe.sync('maybe-missing-file', { ignoreErrors: true })
 Check if the path is executable.  If no callback provided, and a
 global `Promise` object is available, then a Promise will be returned.
 
-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.
 
 ### `isexe.sync(path, [options])`
 
@@ -45,7 +45,7 @@ Same as `isexe` but returns the value and throws any errors raised.
 
 * `ignoreErrors` Treat all errors as "no, this is not executable", but
   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.
diff --git a/access.js b/access.js
deleted file mode 100644
index e67b28b..0000000
--- a/access.js
+++ /dev/null
@@ -1,15 +0,0 @@
-module.exports = isexe
-isexe.sync = sync
-
-var fs = require('fs')
-
-function isexe (path, _, cb) {
-  fs.access(path, fs.X_OK, function (er) {
-    cb(er, !er)
-  })
-}
-
-function sync (path, _) {
-  fs.accessSync(path, fs.X_OK)
-  return true
-}
diff --git a/index.js b/index.js
index ff8ef11..553fb32 100644
--- a/index.js
+++ b/index.js
@@ -2,8 +2,6 @@ var fs = require('fs')
 var core
 if (process.platform === 'win32' || global.TESTING_WINDOWS) {
   core = require('./windows.js')
-} else if (typeof fs.access === 'function') {
-  core = require('./access.js')
 } else {
   core = require('./mode.js')
 }
diff --git a/mode.js b/mode.js
index 2044280..1995ea4 100644
--- a/mode.js
+++ b/mode.js
@@ -4,13 +4,17 @@ isexe.sync = sync
 var fs = require('fs')
 
 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))
   })
 }
 
 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) {
diff --git a/package.json b/package.json
index c86fe74..e452689 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "isexe",
-  "version": "1.1.2",
+  "version": "2.0.0",
   "description": "Minimal module to check if a file is executable.",
   "main": "index.js",
   "directories": {
@@ -9,10 +9,13 @@
   "devDependencies": {
     "mkdirp": "^0.5.1",
     "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"
   },
   "author": "Isaac Z. Schlueter <i at izs.me> (http://blog.izs.me/)",
   "license": "ISC",
diff --git a/test/basic.js b/test/basic.js
index 969fc9a..d926df6 100644
--- a/test/basic.js
+++ b/test/basic.js
@@ -207,5 +207,15 @@ function runTest (t, options) {
     })
   })
 
+  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()
 }
diff --git a/windows.js b/windows.js
index aba8561..3499673 100644
--- a/windows.js
+++ b/windows.js
@@ -24,13 +24,19 @@ function checkPathExt (path, options) {
   return false
 }
 
+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))
   })
 }
 
 function sync (path, options) {
-  fs.statSync(path)
-  return checkPathExt(path, options)
+  return checkStat(fs.statSync(path), path, options)
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-isexe.git



More information about the Pkg-javascript-commits mailing list