isexe
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
Isexe is a lightweight module that checks whether a file is executable and normal. It's designed for Node.js and utilizes fs.stat
to assess the executability of a file. Particularly on Windows, it tests against the PATHEXT
environment variable.
To employ 'isexe', initially install it in your project. You can then import it using either ES6
import or require()
statements, depending on your preference. Here's a basic usage example:
// ES6 import
import { isexe, sync } from 'isexe'
// Or... Using require
const { isexe } = require('isexe')
// Asynchronous usage
isexe('some-file-name').then(isExe => {
if (isExe) {
console.log('This file is executable.')
} else {
console.log('This file is not executable.')
}
}).catch((err) => {
console.error('An error occurred: ', err)
})
// Synchronous usage
try {
const isExe = sync('some-file-name')
if (isExe) {
console.log('This file is executable.')
} else {
console.log('This file is not executable.')
}
} catch (err) {
console.error('An error occurred: ', err)
}
// Ignore errors and just return whether the file is executable or not
const isExe = await isexe('maybe-missing-file', { ignoreErrors: true })
const isExeSync = sync('maybe-missing-file', { ignoreErrors: true })
Note that, if you need to utilize the functionality designed for a specific platform, you can do so by importing the respective version of isexe like win32
or posix
.
The documentation for isexe can be found within the readme file of the isexe Git repository at https://github.com/isaacs/isexe. The documentation provides a full overview of how to use the module, the API, options and implementation details for specific platforms.