UNPKG

@codemod-utils/blueprints

Version:
44 lines (43 loc) 997 B
/** * Returns where `npx` installs the codemod on the user's machine. * * @param fileURL * * Pass the value of `import.meta.url`. * * @return * * The installation path. * * @example * * To read blueprint files, get the path to the `blueprints` folder. * * ```ts * // src/utils/blueprints/blueprints-root.ts * import { join } from 'node:path'; * * const fileURL = import.meta.url; * * const blueprintsRoot = join(getFilePath(fileURL), '../../blueprints'); * * // '<some/absolute/path>/src/blueprints' * ``` * * Afterwards, prepend the file path with `blueprintsRoot`. * * ```ts * import { readFileSync } from 'node:fs'; * import { join } from 'node:path'; * * const blueprintFilePaths = ['LICENSE.md', 'README.md']; * * blueprintFilePaths.forEach((blueprintFilePath) => { * const blueprintFile = readFileSync( * join(blueprintsRoot, blueprintFilePath), * 'utf8', * ); * }); * ``` */ export declare function getFilePath(fileURL: string): string;