pkg-ok
Whether you're publishing a Node, React, Vue, or any kind of module on npm, pkg-ok will do some last minute checks before you publish
- Ensures paths declared in
main
,bin
,module
,typings
andes2015
exists - Ensures
bin
scripts use cross-platform line endings
Also pkg-ok being a devDependency, it won't add to your published module size.
Getting started
Install pkg-ok using npm
npm install pkg-ok --save-dev
or via yarn
yarn add pkg-ok --dev
Then simply add pkg-ok CLI at the end of your prepublishOnly
script
// package.json
{
"scripts": {
"prepublishOnly": "... && pkg-ok"
}
}
Give it a try
If you want to give a try to pkg-ok without publishing, you can change your main
path
// package.json
{
"main": "this/path/doesnt/exist.js",
}
And run prepublishOnly
manually
npm run prepublishOnly
# pkg-ok will give you an error since main path doesn't exist
Options
You can also configure pkg-ok to check additional package.json
fields or bin files
pkgOk --field someField --bin script.sh
Module
You can use pkg-ok as a module
const pkgOk = require('pkg-ok')
const opts = {
fields: ['someField'],
bin: ['script.sh']
}
// Assuming this file is at the same level as package.json
pkgOk(__dirname, opts)
License
MIT - Typicode ๐ต - Patreon