Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

pkg-ok

abraham3.4kMIT3.0.0TypeScript support: included

Checks package.json main and bin paths

package, main, bin, field, file, path, exist, test, crlf, lf, line ending

readme

pkg-ok Build status npm

pkg-ok checks paths and scripts defined in package.json before you publish 👌

  • Ensures paths defined in main, bin, module, types, typings, es2015, browser, and exports exist
  • Ensures paths defined in main, bin, and browser are relative
  • Ensures bin scripts use cross-platform line endings

Usage

npm install pkg-ok --save-dev
// package.json
{
  "main": "oops_this_file_doesnt_exist.js",
  "scripts": {
    "prepublishOnly": "... && pkg-ok"
  }
}
npm publish
# Error!
# Since main file doesn't exist, publish is blocked

CLI

Check the package.json in the current directory.

pkg-ok

Check the package.json in a specific directory.

pkg-ok some/directory

Check additional package.json fields or bin files.

pkg-ok --field someField --bin script.sh

API

const pkgDirectory = __dirname;

pkgOk(pkgDirectory, {
  fields: ['someAdditonalField'],
  bin: ['someAdditionalScript.sh'],
});

License

MIT

changelog

CHANGELOG

3.0.0

  • Require node 12+
  • Switch to ESM
  • Update dependencies
  • Switch to GitHub Actions
  • Remove package-lock.json
  • Format with Prettier
  • Convert to TypeScript
  • Add exports field
  • Use main as default branch
  • Move files to src and compile to dist
  • Check main, bin, and browser paths are relative
  • Support passing a directory to the CLI pkg-ok some/path

2.3.1

  • Change CLI parser (meow)

2.3.0

  • Add browser field

2.2.0

  • Add types which is synonymous with typings

2.1.0

  • Use pkg-ok as a module
  • Add es2015 field for Angular modules

2.0.0

  • Normalizes line ending for files declared in bin field
  • In addition to checking main and bin, checks typings and module fields if present
  • CLI signature has been changed
  • Drop Node 4 support

1.0.0

  • Initial version