From 9e4c6afaf2beafc0a205bf9b4da7524e3cbcb520 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 | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/register.ts b/src/register.ts index 929b7a0..59af42f 100644 --- a/src/register.ts +++ b/src/register.ts @@ -45,15 +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 { - const configLoaderResult = configLoader({ - cwd: options.cwd, - explicitParams, - }); +export function register({ + cwd = options.cwd, + ...explicitParams +}: RegisterParams): () => void { + const configLoaderResult = configLoader({ cwd, explicitParams }); if (configLoaderResult.resultType === "failed") { console.warn(