Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

readme.md 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # resolve-from [![Build Status](https://travis-ci.org/sindresorhus/resolve-from.svg?branch=master)](https://travis-ci.org/sindresorhus/resolve-from)
  2. > Resolve the path of a module like [`require.resolve()`](http://nodejs.org/api/globals.html#globals_require_resolve) but from a given path
  3. Unlike `require.resolve()` it returns `null` instead of throwing when the module can't be found.
  4. ## Install
  5. ```
  6. $ npm install --save resolve-from
  7. ```
  8. ## Usage
  9. ```js
  10. const resolveFrom = require('resolve-from');
  11. // there's a file at `./foo/bar.js`
  12. resolveFrom('foo', './bar');
  13. //=> '/Users/sindresorhus/dev/test/foo/bar.js'
  14. ```
  15. ## API
  16. ### resolveFrom(fromDir, moduleId)
  17. #### fromDir
  18. Type: `string`
  19. Directory to resolve from.
  20. #### moduleId
  21. Type: `string`
  22. What you would use in `require()`.
  23. ## Tip
  24. Create a partial using a bound function if you want to require from the same `fromDir` multiple times:
  25. ```js
  26. const resolveFromFoo = resolveFrom.bind(null, 'foo');
  27. resolveFromFoo('./bar');
  28. resolveFromFoo('./baz');
  29. ```
  30. ## License
  31. MIT © [Sindre Sorhus](http://sindresorhus.com)