Package Exports
- @inquirerer/utils
- @inquirerer/utils/esm/index.js
- @inquirerer/utils/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@inquirerer/utils) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@inquirerer/utils
CLI lifecycle utilities
Utilities for building command-line applications with inquirerer
CLI lifecycle utilities for building command-line applications with inquirerer.
Installation
npm install @inquirerer/utilsFeatures
extractFirst
Extracts the first positional argument from argv for command routing:
import { extractFirst } from '@inquirerer/utils';
const { first, newArgv } = extractFirst(argv);
// first = 'init' (the subcommand)
// newArgv = remaining arguments with first positional removedcliExitWithError
Exits the CLI with an error message and optional cleanup:
import { cliExitWithError } from '@inquirerer/utils';
await cliExitWithError(error, {
beforeExit: async () => {
await closeConnections();
}
});checkForUpdates
Checks for package updates with caching:
import { checkForUpdates } from '@inquirerer/utils';
const result = await checkForUpdates({
pkgName: '@my/cli',
pkgVersion: '1.0.0',
registryBaseUrl: 'https://registry.npmjs.org'
});
if (result.hasUpdate) {
console.log(result.message);
}getSelfPackageJson
Gets the package.json for the current package:
import { getSelfPackageJson, getSelfVersion, getSelfName } from '@inquirerer/utils';
const pkg = getSelfPackageJson(__dirname);
const version = getSelfVersion(__dirname);
const name = getSelfName(__dirname);License
MIT
Development
Setup
- Clone the repository:
git clone https://github.com/constructive-io/dev-utils.git- Install dependencies:
cd dev-utils
pnpm install
pnpm build- Test the package of interest:
cd packages/<packagename>
pnpm test:watchCredits
Built for developers, with developers.
👉 https://launchql.com | https://hyperweb.io
Disclaimer
AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.