Innovenergy_trunk/frontend/node_modules/resolve-cwd/node_modules/resolve-from
Kim 085d7c68ba adding untracked frontend and typescript files 2023-02-21 07:27:20 +01:00
..
index.js adding untracked frontend and typescript files 2023-02-21 07:27:20 +01:00
license adding untracked frontend and typescript files 2023-02-21 07:27:20 +01:00
package.json adding untracked frontend and typescript files 2023-02-21 07:27:20 +01:00
readme.md adding untracked frontend and typescript files 2023-02-21 07:27:20 +01:00

readme.md

resolve-from Build Status

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

Unlike require.resolve() it returns null instead of throwing when the module can't be found.

Install

$ npm install --save resolve-from

Usage

const resolveFrom = require('resolve-from');

// there's a file at `./foo/bar.js`

resolveFrom('foo', './bar');
//=> '/Users/sindresorhus/dev/test/foo/bar.js'

API

resolveFrom(fromDir, moduleId)

fromDir

Type: string

Directory to resolve from.

moduleId

Type: string

What you would use in require().

Tip

Create a partial using a bound function if you want to require from the same fromDir multiple times:

const resolveFromFoo = resolveFrom.bind(null, 'foo');

resolveFromFoo('./bar');
resolveFromFoo('./baz');

License

MIT © Sindre Sorhus