Skip to content

joaquimserafim/module-resolve

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

module-resolve

use the require.resolve to look up the location of a module but return true in case of finding or false in case of not finding

Build StatusCode Coverage 100%ISC License

API

var resolve = require('module-resolve')

resolve(module:string) - verify module is installed

  • module - can be the name of the module or the path

resolse.load(module:string) - require/load the module

  • module - can be the name of the module or the path

Usage

var resolve = require('module-resolve')

// `npm i express`

// should return true
resolve('express')
// should return false
resolve('qs')
// should return true
resolve('./node_modules/express/node_modules/qs')

// the same as `var express = require('express')`
// instead throwing an error returns "undefined" if module is not installed
var express = resolve.load('express')

Development

this projet has been set up with a precommit that forces you to follow a code style, no jshint issues and 100% of code coverage before commit

to run test

npm test

to run jshint

npm run jshint

to run code style

npm run code-style

to run check code coverage

npm run check-coverage

to open the code coverage report

npm run open-coverage

About

try to find an installed module without throwing an error

Resources

License

Stars

Watchers

Forks

Packages

No packages published