opt-cli is a Node.js utility designed to conditionally execute CLI statements based on opt-in or opt-out rules. Its primary use case, as highlighted in its documentation, is for managing `ghooks` or similar pre-commit/pre-push scripts, allowing developers to enable or disable specific tasks without modifying `package.json` scripts directly. Rules are defined in `.opt-in` or `.opt-out` files in the project root, or via the `config.opt` field in `package.json`. The package has been stable at version 1.6.0 since October 2017, with no further releases or active development observed, indicating an abandoned status. It explicitly supports Node.js versions `>=4` and primarily functions as a CommonJS module, without apparent ESM support.
npm install opt-cliVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to use `opt-cli` programmatically to check opt-in and opt-out rules by simulating the creation of `.opt-in` and `.opt-out` files, and then using `testOptIn` and `testOptOut` methods. It also illustrates how to retrieve combined explicit configurations and suggests CLI usage.
Use CommonJS `const opt = require('opt-cli');` in CJS files, or consider a build step (e.g., Babel, Webpack) for ESM projects that need to consume CJS packages.Evaluate the necessity of this package. For new projects, consider modern alternatives or implement similar logic manually. For existing projects, be aware of the lack of maintenance and potential security implications.
Thoroughly test `opt-cli` against your target Node.js version. If issues arise, a manual fork and fix, or migration to an alternative, may be necessary.
Upgrade to `opt-cli` version 1.5.0 or later immediately. Given the project's abandoned status, further security issues will not be patched.
Ensure your file is treated as CommonJS (e.g., `.js` file without `"type": "module"` in `package.json`, or explicitly `.cjs` extension) when using `require`. If your project is ESM, `opt-cli` cannot be directly imported; consider a wrapper or alternative.
Verify `opt-cli` is correctly installed (`npm list opt-cli`). Ensure the `require('opt-cli')` statement is at the top level of your CommonJS module. Check that the file where `require` is used is indeed treated as CommonJS.Ensure the `.opt-in` or `.opt-out` files are present in the root of your project (or `process.cwd()`). Verify file permissions allow Node.js to read them. Alternatively, specify rules within the `config.opt` field of your `package.json`.
No dependency data recorded yet.