resolve-from-fallback
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

resolve-from-fallback

Build status Test coverage NPM version NPM Downloads Prettier Conventional Commits

Resolve the path of a module like require.resolve() but from some fallback path

Installation

npm install resolve-from-fallback
# or use yarn 
yarn add resolve-from-fallback

Usage

const resolveFromFallback = require('resolve-from-fallback')
 
const resolveLocal = (id) => resolveFromFallback([process.cwd(), __dirname], id)
 
resolveLocal('react') // resolve react path from `process.cwd()` or `__dirname`
 
resolveLocal('not_found') // Throw MODULE_NOT_FOUND error
 
resolveLocal.silent([process.cwd(), __dirname], 'not_found') // Return undefined

Contributing

  • Fork it!
  • Create your new branch:
    git checkout -b feature-new or git checkout -b fix-which-bug
  • Start your magic work now
  • Make sure npm test passes
  • Commit your changes:
    git commit -am 'feat: some description (close #123)' or git commit -am 'fix: some description (fix #123)'
  • Push to the branch: git push
  • Submit a pull request :)

Authors

This library is written and maintained by 余聪, yucong06@meituan.com.

License

MIT - 余聪 🐟

Package Sidebar

Install

npm i resolve-from-fallback

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

6.96 kB

Total Files

6

Last publish

Collaborators

  • moyuyc