From 1a24f2ac686f5ebc3802711a4dc83e52f7b3d963 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Tue, 25 Jan 2022 16:26:26 +0100 Subject: [PATCH] fix: default _filename if null or falsy value passed --- src/jiti.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/jiti.ts b/src/jiti.ts index d844f32a..eeafaeee 100644 --- a/src/jiti.ts +++ b/src/jiti.ts @@ -34,7 +34,7 @@ export interface JITI extends Require { register: () => (() => void) } -export default function createJITI (_filename: string = process.cwd(), opts: JITIOptions = {}, parentModule?: typeof module): JITI { +export default function createJITI (_filename: string, opts: JITIOptions = {}, parentModule?: typeof module): JITI { opts = { ...defaults, ...opts } // Cache dependencies @@ -53,6 +53,9 @@ export default function createJITI (_filename: string = process.cwd(), opts: JIT } // If filename is dir, createRequire goes with parent directory, so we need fakepath + if (!_filename) { + _filename = process.cwd() + } if (isDir(_filename)) { _filename = join(_filename, 'index.js') }