Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shinnn/reject-unsatisfied-npm-version
Make a Promise rejection unless the currently installed npm CLI satisfies the required version
https://github.com/shinnn/reject-unsatisfied-npm-version
async javascript nodejs npm promise rejection version
Last synced: 27 days ago
JSON representation
Make a Promise rejection unless the currently installed npm CLI satisfies the required version
- Host: GitHub
- URL: https://github.com/shinnn/reject-unsatisfied-npm-version
- Owner: shinnn
- License: isc
- Created: 2018-07-11T01:07:56.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-07-11T01:18:08.000Z (over 6 years ago)
- Last Synced: 2024-09-15T04:41:17.444Z (2 months ago)
- Topics: async, javascript, nodejs, npm, promise, rejection, version
- Language: JavaScript
- Size: 23.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# reject-unsatisfied-npm-version
[![npm version](https://img.shields.io/npm/v/reject-unsatisfied-npm-version.svg)](https://www.npmjs.com/package/reject-unsatisfied-npm-version)
[![Build Status](https://travis-ci.com/shinnn/reject-unsatisfied-npm-version.svg?branch=master)](https://travis-ci.com/shinnn/reject-unsatisfied-npm-version)
[![Coverage Status](https://img.shields.io/coveralls/shinnn/reject-unsatisfied-npm-version.svg)](https://coveralls.io/github/shinnn/reject-unsatisfied-npm-version)[Make a `Promise` rejection](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject) unless the currently installed [npm CLI](https://github.com/npm/npm) satisfies the required version
```javascript
const rejectUnsatisfiedNpmVersion = require('reject-unsatisfied-npm-version');// When `npm --version` prints `6.1.0`
(async () => {
await rejectUnsatisfiedNpmVersion('6.0.0'); // not rejected
await rejectUnsatisfiedNpmVersion('6.1.0'); // not rejectedtry {
await rejectUnsatisfiedNpmVersion('6.2.0');
} catch (err) {
err.message; //=> 'Expected a version of npm CLI to be 6.2.0 or greater, but an older version 6.1.0 is installed. Run the command `npm install --global npm` to install the latest one.'
err.code; //=> 'ERR_TOO_OLD_NPM'
}
})();
```Useful for applications and libraries which requires a newer version of `npm`.
## Installation
[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/getting-started/what-is-npm).
```
npm install reject-unsatisfied-npm-version
```## API
```javascript
const rejectUnsatisfiedNpmVersion = require('reject-unsatisfied-npm-version');
```### rejectUnsatisfiedNpmVersion(*requiredNpmVersion*)
*requiredNpmVersion*: `string` (minimum required `npm` version as a [SemVer](https://semver.org/#semantic-versioning-specification-semver) expression)
Return: `Promise`## License
[ISC License](./LICENSE) © 2018 Shinnosuke Watanabe