Skip to content

Commit

Permalink
Revert "Remove ability to specify "requires" in tsconfig"
Browse files Browse the repository at this point in the history
This reverts commit 700a90f.
  • Loading branch information
cspotcode committed Dec 14, 2019
1 parent 80ea06c commit e7690b9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/bin.ts
Expand Up @@ -87,7 +87,7 @@ export function main (argv: string[]) {
'--help': help = false,
'--script-mode': scriptMode = false,
'--version': version = 0,
'--require': requires = [],
'--require': argsRequire = [],
'--eval': code = undefined,
'--print': print = false,
'--interactive': interactive = false,
Expand Down Expand Up @@ -190,6 +190,8 @@ export function main (argv: string[]) {
: undefined
})

const requires = argsRequire.length !== 0 ? argsRequire : service.options.requires || []

// Output project information.
if (version >= 2) {
console.log(`ts-node v${VERSION}`)
Expand Down
12 changes: 11 additions & 1 deletion src/index.ts
Expand Up @@ -166,7 +166,9 @@ export interface TsConfigOptions
| 'skipProject'
| 'project'
| 'dir'
> {}
> {
requires?: Array<string>
}

/**
* Like Object.assign or splatting, but never overwrites with `undefined`.
Expand Down Expand Up @@ -789,6 +791,14 @@ function readConfig (
useCaseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames
}, basePath, undefined, configFileName))

if (tsconfigOptions.requires) {
// Relative paths are relative to the tsconfig's parent directory, not the `dir` option
tsconfigOptions.requires = tsconfigOptions.requires.map((path: string) => {
if (path.startsWith('.')) return resolve(configFileName!, '..', path)
return path
})
}

return { config: fixedConfig, options: tsconfigOptions }
}

Expand Down

0 comments on commit e7690b9

Please sign in to comment.