shellcheck

ShellCheck - A shell script static analysis tool.
Downloads the most recent version of koalaman's ShellCheck.
Installation
Warning: Node.js version >= 18.12.0
is required
npm install --save-dev shellcheck
Usage
Note: On first execution shellcheck
it's automatically downloaded
Note: It's recommended to execute shellcheck
using npx
Note: Proxy support via HTTP_PROXY
, HTTPS_PROXY
and NO_PROXY
environment variables
Note: By default, all GitHub requests are anonymous. If you encounter error 403 | rate limit exceeded
(e.g., in CI), set the environment variable GITHUB_TOKEN
to use your own personal access token
Execute shellcheck
directly from your npm scripts:
{
"scripts": {
"lint": "npx shellcheck path/to/script.sh"
}
}
Environment Variables
Name | Values | Default | Description |
---|
SHELLCHECKJS_RELEASE | latest | v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*) | latest | Release version. See https://github.com/koalaman/shellcheck/releases |
SHELLCHECK_BIN | Any valid path to an executable binary file | linux or darwin: ./bin/shellcheck win32: .\bin\shellcheck.exe | ShellCheck executable binary path |
SHELLCHECKJS_LOGGER_LEVEL | off | debug | info | warn | error | info | Logger level |
Programmatic
Note: More functions, utilities, and constants are available
import { shellcheck, download, config } from 'shellcheck';
await shellcheck({
args: ['path/to/script.sh', 'path/to/another/script.sh']
})
.then((result) => {
if (result.error) throw result.error;
if (result.stdout) console.log(result.stdout.toString('utf8'));
if (result.stderr) console.error(result.stderr.toString('utf8'));
if (result?.status !== 0) throw new Error(`Exit code: ${result?.status}`);
})
.catch((err) => {
console.error(`Error: ${err}`);
throw err;
});
await download({
destination: `path/to/destination/shellcheck`
});
Compatibility
Note: Platform
and Architecture
follow Node.js naming convention
Platform | Architecture |
---|
linux | x64 |
linux | arm64 |
darwin | x64 |
darwin | arm64 |
win32 | x64 |
Contributing
I would love to see your contribution :heart:
See CONTRIBUTING guidelines.
License
This project is licensed under the MIT License.
See LICENSE file for details.