export type ProviderCreator = import('../shared/jimpleFns').ProviderCreator; export type PathUtilsProviderOptions = { /** * The name that will be used to register an instance of * {@link PathUtils }. Its default value is `pathUtils`. */ serviceName: string; /** * The path to the new home location. */ home?: string; }; /** * @module node/pathUtils */ /** * @typedef {import('../shared/jimpleFns').ProviderCreator} ProviderCreator * @template O */ /** * @typedef {Object} PathUtilsProviderOptions * @property {string} serviceName The name that will be used to register an instance of * {@link PathUtils}. Its default value is `pathUtils`. * @property {string} [home] The path to the new home location. * @parent module:node/pathUtils */ /** * A utility services to manage paths on a project. It allows for path building relatives * to the project root or from where the app executable is located. * * @parent module:node/pathUtils * @tutorial pathUtils */ export class PathUtils { /** * @param {string} [home=''] The location of the project's `home`(root) directory. By * default it uses `process.cwd()`. */ constructor(home?: string); /** * The root path from where the app is being executed. * * @type {string} * @access protected * @ignore */ _path: string; /** * A dictionary of different path locations. * * @type {Object.} * @access protected * @ignore */ _locations: { [x: string]: string; }; /** * Adds a new location. * * @param {string} name The reference name. * @param {string} locationPath The path of the location. It must be inside the path * from the app is being executed. */ addLocation(name: string, locationPath: string): void; /** * Gets a location path by its name. * * @param {string} name The location name. * @returns {string} * @throws {Error} If there location hasn't been added. */ getLocation(name: string): string; /** * Alias to `joinFrom` that uses the `home` location by default. * * @param {...string} paths The rest of the path components to join. * @returns {string} */ join(...paths: string[]): string; /** * Builds a path using a location path as base. * * @param {string} location The location name. * @param {...string} paths The rest of the path components to join. * @returns {string} */ joinFrom(location: string, ...paths: string[]): string; /** * The path to the directory where the app executable is located. * * @type {string} */ get app(): string; /** * The project root path. * * @type {string} */ get home(): string; /** * A dictionary of different path locations. * * @type {Object.} * @access protected * @ignore */ get locations(): { [x: string]: string; }; /** * The root path from where the app is being executed. * * @type {string} * @access protected * @ignore */ get path(): string; /** * Finds and register the location for the app executable directory. * * @access protected * @ignore */ _addAppLocation(): void; } /** * The service provider to register an instance of {@link PathUtils} on the container. * * @type {ProviderCreator} * @tutorial pathUtils */ export const pathUtils: ProviderCreator;