Skip to content

Commit

Permalink
fix(which): replace constant to support earlier versions of NodeJS (#657
Browse files Browse the repository at this point in the history
)
  • Loading branch information
termosa committed Jul 12, 2018
1 parent 79b8feb commit 2369ccd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/which.js
Expand Up @@ -13,14 +13,17 @@ common.register('which', _which, {
// set on Windows.
var XP_DEFAULT_PATHEXT = '.com;.exe;.bat;.cmd;.vbs;.vbe;.js;.jse;.wsf;.wsh';

// For earlier versions of NodeJS that doesn't have a list of constants (< v6)
const FILE_EXECUTABLE_MODE = 1;

// Cross-platform method for splitting environment `PATH` variables
function splitPath(p) {
return p ? p.split(path.delimiter) : [];
}

function isExecutable(pathName) {
try {
fs.accessSync(pathName, fs.constants.X_OK);
fs.accessSync(pathName, FILE_EXECUTABLE_MODE);
} catch (err) {
return false;
}
Expand Down

0 comments on commit 2369ccd

Please sign in to comment.