package-missing
This very simple but incredibly useful package contains a Constructor for the `PackageMissingError`.
Last updated 4 years ago by leichtgewicht .
ISC · Original npm · Tarball · package.json
$ cnpm install package-missing 
SYNC missed versions from official npm registry.

Build Status Coverage Status js-standard-style

package-missing

This, very simple but incredibly useful package contains a Constructor for the PackageMissingError.

Usage

const PackageMissingError = require('package-missing')

// What would work if another package was installed?
const task = 'Can not parse the file test.yml'

// What packages can be installed to make this work?
const recommendedPackages = [ 'js-yaml', 'yaml' ]

const error = new PackageMissingError(task, recommendedPackages)

// You can test for this code
error.code === 'EPACKAGEMISSING'

// ... or for the package-missing-error
error instanceof PackageMissingError

// The input is available to be processed
error.task === task
error.recommendedPackages === recommendedPackages

// The message recommends to install the mentioned packages
error.message === error.code + ': ' + error.message + '\n'
    + 'This error can be easily fixed by running ONE of the following commands:\n'
    + recommendedPackages.map((pkg) => '- $ npm install ' + pkg + ' --save').join('\n')

// The error comes with a stack, but if you don't like it ...
typeof error.stack === 'string'

License

ISC

Current Tags

  • 1.1.0                                ...           latest (4 years ago)

2 Versions

  • 1.1.0                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (2)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |