From 9d2005ebf91e93b7bc484653185730d342677111 Mon Sep 17 00:00:00 2001 From: Alec Larson <1925840+aleclarson@users.noreply.github.com> Date: Fri, 8 Apr 2022 20:30:46 -0400 Subject: [PATCH] feat(register): add `cwd` param --- src/register.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/register.ts b/src/register.ts index 929b7a0..8812b51 100644 --- a/src/register.ts +++ b/src/register.ts @@ -45,14 +45,22 @@ function getCoreModules( return coreModules; } +export interface RegisterParams extends ExplicitParams { + /** + * Defaults to `--project` CLI flag or `process.cwd()` + */ + cwd?: string; +} + /** * Installs a custom module load function that can adhere to paths in tsconfig. * Returns a function to undo paths registration. */ -export function register(explicitParams: ExplicitParams): () => void { +export function register(params?: RegisterParams): () => void { const configLoaderResult = configLoader({ - cwd: options.cwd, - explicitParams, + cwd: params?.cwd ?? options.cwd, + explicitParams: + params && (params.baseUrl || params.paths) ? params : undefined, }); if (configLoaderResult.resultType === "failed") {