1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
declare namespace resolvePkg {
interface Options {
/**
Directory to resolve from.
@default process.cwd()
*/
readonly cwd?: string;
}
}
/**
Resolve the path of a package regardless of it having an entry point.
@param moduleId - What you would use in `require()`.
@example
```
import resolvePkg = require('resolve-pkg');
// $ npm install --save-dev grunt-svgmin
resolvePkg('grunt-svgmin/tasks', {cwd: __dirname});
//=> '/Users/sindresorhus/unicorn/node_modules/grunt-svgmin/tasks'
// Fails here as Grunt tasks usually don't have a defined main entry point
require.resolve('grunt-svgmin/tasks');
//=> Error: Cannot find module 'grunt-svgmin'
```
*/
declare function resolvePkg(
moduleId: string,
options?: resolvePkg.Options
): string | undefined;
export = resolvePkg;
|