1.0.0 • Published 5 years ago

resolve-from-fallback v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

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 - 余聪 🐟

1.0.0

5 years ago