Prepare bin scripts for publishing.
If you find this repo useful, stars are appreciated ⭐️
DM me on Twitter if you have questions or suggestions.
Bin scripts require a hashbang to run properly:
#!/usr/bin/env node
However, if you're using TypeScript, you'll need to compile to JavaScript before publishing.
This package searches for each file in the bin
field of your package.json
, and prepends the Node shebang to the file if it doesn't already have one.
Additionally, autobin sets the executable bits on the file. Although this is not required as package managers set the executable bits when installing, it allows you to run the script directly before publishing.
yarn add --dev autobin
npm install --save-dev autobin
pnpm add --save-dev autobin
In your package.json
file:
{
"scripts": {
"postbuild": "autobin"
}
}
The "postbuild" script automatically runs after the "build" script is run.
Alternatively, you can run autobin
directly from the command line:
yarn autobin
npm run autobin
pnpm run autobin
- @bconnorwhite/package: A utility for reading package.json of a project, and forming paths relative to it.
- clee: Create CLI applications with glee 🎉
- make-executable: Set the executable bits on a file
- read-file-safe: Read files without try catch
- write-file-safe: Write files atomically and create parent directories if necessary
- @autossey/eslint-config: A base for projects that use ESLint.
- @autossey/tsconfig: A collection of base TSConfigs for various types of projects.
- npm-package-json-lint-config-auto: NPM Package.json Lint Config
MIT - The MIT License
- autorepo: Autorepo abstracts away your dev dependencies, providing a single command to run all of your scripts.