is-resolvable
Advanced tools
Comparing version 1.0.0 to 1.0.1
24
index.js
'use strict'; | ||
var tryit = require('tryit'); | ||
var inspect = require('util').inspect; | ||
module.exports = function isResolvable(moduleId) { | ||
if (typeof moduleId !== 'string') { | ||
throw new TypeError( | ||
moduleId + | ||
' is not a string. A module identifier to be checked if resolvable is required.' | ||
); | ||
throw new TypeError(inspect(moduleId) + ' is not a string. Expected a valid Node.js module identifier (<string>), for example \'eslint\', \'./index.js\', \'./lib\'.'); | ||
} | ||
var result; | ||
tryit(function() { | ||
try { | ||
require.resolve(moduleId); | ||
}, function(err) { | ||
if (err) { | ||
result = false; | ||
return; | ||
} | ||
result = true; | ||
}); | ||
return result; | ||
return true; | ||
} catch (err) { | ||
return false; | ||
} | ||
}; |
{ | ||
"name": "is-resolvable", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Check if a module ID is resolvable with require()", | ||
@@ -8,5 +8,5 @@ "repository": "shinnn/is-resolvable", | ||
"scripts": { | ||
"pretest": "eslint --config node_modules/@shinnn/eslintrc-node/rc.json index.js test.js", | ||
"test": "node test.js", | ||
"coverage": "istanbul cover test.js" | ||
"pretest": "eslint --fix --format=codeframe index.js test.js", | ||
"test": "node --throw-deprecation --track-heap-objects test.js", | ||
"coverage": "istanbul cover --print=both test.js" | ||
}, | ||
@@ -18,23 +18,21 @@ "license": "MIT", | ||
"keywords": [ | ||
"read", | ||
"file", | ||
"font", | ||
"glyph", | ||
"code-point", | ||
"unicode", | ||
"parse", | ||
"cmap", | ||
"table", | ||
"data", | ||
"metadata" | ||
"path", | ||
"resolve", | ||
"resolvable", | ||
"check", | ||
"module" | ||
], | ||
"dependencies": { | ||
"tryit": "^1.0.1" | ||
"devDependencies": { | ||
"@shinnn/eslint-config-node": "^4.0.2", | ||
"eslint": "^4.11.0", | ||
"istanbul": "^0.4.5", | ||
"tape": "^4.8.0" | ||
}, | ||
"devDependencies": { | ||
"@shinnn/eslintrc-node": "^1.0.2", | ||
"eslint": "^0.24.0", | ||
"istanbul": "^0.3.17", | ||
"tape": "^4.0.0" | ||
"eslintConfig": { | ||
"extends": "@shinnn/node", | ||
"rules": { | ||
"no-var": "off" | ||
} | ||
} | ||
} |
@@ -7,4 +7,4 @@ # is-resolvable | ||
[![Coverage Status](https://img.shields.io/coveralls/shinnn/is-resolvable.svg)](https://coveralls.io/r/shinnn/is-resolvable) | ||
[![Dependency Status](https://img.shields.io/david/shinnn/is-resolvable.svg?label=deps)](https://david-dm.org/shinnn/is-resolvable) | ||
[![devDependency Status](https://img.shields.io/david/dev/shinnn/is-resolvable.svg?label=devDeps)](https://david-dm.org/shinnn/is-resolvable#info=devDependencies) | ||
[![Dependency Status](https://david-dm.org/shinnn/is-resolvable.svg)](https://david-dm.org/shinnn/is-resolvable) | ||
[![devDependency Status](https://david-dm.org/shinnn/is-resolvable/dev-status.svg)](https://david-dm.org/shinnn/is-resolvable#info=devDependencies) | ||
@@ -67,4 +67,4 @@ A [Node](https://nodejs.org/) module to check if a module ID is resolvable with [`require()`](https://nodejs.org/api/globals.html#globals_require) | ||
Copyright (c) 2014 - 2015 [Shinnosuke Watanabe](https://github.com/shinnn) | ||
Copyright (c) 2014 - 2016 [Shinnosuke Watanabe](https://github.com/shinnn) | ||
Licensed under [the MIT License](./LICENSE). |
Sorry, the diff of this file is not supported yet
0
4520
13
- Removedtryit@^1.0.1
- Removedtryit@1.0.3(transitive)