Skip to content

Commit

Permalink
fix: default _filename if null or falsy value passed
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Jan 25, 2022
1 parent 06fd2d4 commit 1a24f2a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/jiti.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')
}
Expand Down

0 comments on commit 1a24f2a

Please sign in to comment.