lib/file/access/index.js
function executableBy(file, user) {
  if (!exists(file)) {
    return false;
  }
  const userData = findUser(user);
  if (userData.id === 0) {
    // Root can do anything but execute a file with no exec permissions
    const mode = fs.lstatSync(file).mode;
    return !!(mode & parseInt('00111', 8));
  } else if (userData.id === process.getuid()) {
    return executable(file);
  } else {
    return _accesibleByUser(userData, file, fs.X_OK);
  }
}
function executableBy(file, user) {
  if (!exists(file)) {
    return false;
  }
  const userData = findUser(user);
  if (userData.id === 0) {
    // Root can do anything but execute a file with no exec permissions
    const mode = fs.lstatSync(file).mode;
    return !!(mode & parseInt('00111', 8));
  } else if (userData.id === process.getuid()) {
    return executable(file);
  } else {
    return _accesibleByUser(userData, file, fs.X_OK);
  }
}
function executableBy ( file , user ) { if ( ! exists ( file ) ) { return false ; } const userData = findUser ( user ) ; if ( userData . id === 0 ) { // Root can do anything but execute a file with no exec permissions const mode = fs . lstatSync ( file ) . mode ; return ! ! ( mode & parseInt ( '00111' , 8 ) ) ; } else if ( userData . id === process . getuid ( ) ) { return executable ( file ) ; } else { return _accesibleByUser ( userData , file , fs . X_OK ) ; } }
Check whether a file is executable or not by a given user
@function $file~executable
@param {string} file
@param {string|number} user - Username or user id to check permissions for
@returns {boolean}
@example
// Check if '/bin/ls' is executable by the 'nobody' user
$file.executable('/bin/ls', 'nobody');
// => true
Check whether a file is executable or not by a given user