Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/core/helpers/resolveFromCwd.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import path from 'path';

/**
* Resolves a path relative to the current working directory.
* @param cwd - Current working directory
* @param p - Path to resolve
* @returns Resolved absolute path
* Resolves a filesystem path relative to a given current working directory (CWD).
*
* This helper is useful when working with user-provided paths that may be
* relative or absolute.
*
* - Absolute paths are returned unchanged.
* - Relative paths are resolved against `cwd` using `path.resolve`.
*
* @param cwd - Base directory used to resolve relative paths
* @param p - A relative or absolute filesystem path
* @returns An absolute filesystem path
*/
export const resolveFromCwd = (cwd: string, p: string): string =>
path.isAbsolute(p) ? p : path.resolve(cwd, p);
Loading