Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shinnn/broken-npm-path
A path to the mock file that simulates an incorrectly installed npm CLI
https://github.com/shinnn/broken-npm-path
Last synced: 27 days ago
JSON representation
A path to the mock file that simulates an incorrectly installed npm CLI
- Host: GitHub
- URL: https://github.com/shinnn/broken-npm-path
- Owner: shinnn
- License: isc
- Created: 2018-08-24T02:08:20.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-06-07T12:46:07.000Z (over 5 years ago)
- Last Synced: 2024-10-14T05:02:19.225Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 15.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# broken-npm-path
[![npm version](https://img.shields.io/npm/v/broken-npm-path.svg)](https://www.npmjs.com/package/broken-npm-path)
[![Github Actions](https://action-badges.now.sh/shinnn/broken-npm-path)](https://wdp9fww0r9.execute-api.us-west-2.amazonaws.com/production/results/shinnn/broken-npm-path)A path to the mock file that simulates an incorrectly installed [npm CLI](https://github.com/npm/cli)
```javascript
const childProcess = require('child_process');
const {promisify} = require('util');
const brokenNpmPath = require('broken-npm-path');const execFile = promisify(childProcess.execFile);
(async () => {
await execFile('node', [process.env.npm_execpath, '--version']);
//=> {stdout: '6.9.0\n', stderr: ''}process.env.npm_execpath = brokenNpmPath;
await execFile('node', [process.env.npm_execpath, '--version']);
// throws an Error: npm CLI is not correctly installed.
})();
```This module is useful for the situation where a user tries to test any libraries and applications depending on npm CLI, and needs to cover the case when npm CLI is not correctly installed for some reason.
## Installation
[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/about-npm/).
```
npm install broken-npm-path
```## API
```javascript
const brokenNpmPath = require('broken-npm-path');
```### brokenNpmPath
Type: `string`
A path to the intentionally [broken npm CLI entry point](https://github.com/shinnn/broken-npm-path/blob/master/lib/node_modules/npm/bin/npm-cli.js), which throws an error whenever it's run.
## License
[ISC License](./LICENSE) © 2018 - 2019 Watanabe Shinnosuke