Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

Commit

Permalink
fix: set cwd to project root when loading ts-node
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed May 1, 2018
1 parent 0b24453 commit d120ec1
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions src/ts_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,25 @@ function registerTSNode(root: string) {
} else {
rootDirs.push(`${root}/src`)
}
tsNode.register({
skipProject: true,
transpileOnly: true,
// cache: false,
// typeCheck: true,
compilerOptions: {
target: tsconfig.compilerOptions.target || 'es2017',
module: 'commonjs',
sourceMap: true,
rootDirs,
typeRoots,
}
})
const cwd = process.cwd()
try {
process.chdir(root)
tsNode.register({
skipProject: true,
transpileOnly: true,
// cache: false,
// typeCheck: true,
compilerOptions: {
target: tsconfig.compilerOptions.target || 'es2017',
module: 'commonjs',
sourceMap: true,
rootDirs,
typeRoots,
}
})
} finally {
process.chdir(cwd)
}
}

function loadTSConfig(root: string): TSConfig | undefined {
Expand Down

0 comments on commit d120ec1

Please sign in to comment.