broken-npm-path

1.0.0 • Public • Published

broken-npm-path

npm version Build Status

A path to the mock file that simulates an incorrectly installed npm CLI

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.4.0\n', stderr: ''}
 
    process.env.npm_execpath = brokenNpmMock.bin;
 
    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 npm.

npm install broken-npm-path

API

const brokenNpmPath = require('broken-npm-path');

brokenNpmPath

Type: string

A path to the intentionally broken npm CLI entry point, which throws an error whenever it's run.

License

ISC License © 2018 Shinnosuke Watanabe

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    1
  • 0.0.0
    1

Package Sidebar

Install

npm i broken-npm-path

Weekly Downloads

2

Version

1.0.0

License

ISC

Unpacked Size

3.43 kB

Total Files

6

Last publish

Collaborators

  • shinnn