UNPKG

pertain

Version:

Automated pub/sub across project dependencies. Run code from any installed package based on declarative rules in package.json

41 lines (40 loc) 1.38 kB
import PackageJson from './PackageJson'; export type DependencyFinder = (found: string[], packageJson: PackageJson, rootDir: string, subject: string) => string[]; /** * A Node package which declares in its `package.json` file that it contains * a script module which pertains to a particular subject. Use this object * to require the pertaining module and/or report the name of the subscriber. */ export interface Pertaining { /** * The name of the package.. * @example "@org/package-name" */ name: string; /** * The real path of the package root. * @example "/Users/you/project/node_modules/@org/package-name" */ modulePath: string; /** * The filesystem path of the package's root directory. * @example "/var/www/venia/node_modules/@org/package-name" */ path: string; /** * The subject that was originally passed to `pertain()` to produce this * object. * @example "pwa.webpack" */ subject: string; } /** * Query the direct dependencies of the Node project at `rootDir` for all * packages which have a particular `package.json` property. Return them in * peerDependency order. */ declare function pertain(rootDir: string, subject: string, getDependencies?: DependencyFinder): Pertaining[]; declare namespace pertain { var clearCache: () => void; } export default pertain;