How do I check if a file is executable in node.js?
Maybe something like
fs.isExecutable(function (isExecutable) {
})
Another option that relies only on the built-in fs
module is to use either fs.access or fs.accessSync. This method is easier than getting and parsing the file mode. An example:
const fs = require('fs');
fs.access('./foobar.sh', fs.constants.X_OK, (err) => {
console.log(err ? 'cannot execute' : 'can execute');
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With