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

Commit

Permalink
fix: add rootDir from tsconfig for plugins that use it (#39)
Browse files Browse the repository at this point in the history
* fix: add rootDir from tsconfig for plugins that use it

* fix: use better conditional format which defaults to rootDir
  • Loading branch information
amphro authored and jdx committed Jun 18, 2018
1 parent 7c5284d commit a6078d1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/ts_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const debug = Debug()

export interface TSConfig {
compilerOptions: {
rootDir?: string
rootDirs?: string[]
outDir?: string
target?: string
Expand Down Expand Up @@ -82,12 +83,12 @@ export function tsPath(root: string, orig: string | undefined): string | undefin
registerTSNode(root)
const tsconfig = tsconfigs[root]
if (!tsconfig) return orig
const {rootDirs, outDir} = tsconfig.compilerOptions
const rootDir = (rootDirs || [])[0]
if (!rootDir || !outDir) return orig
const {rootDir, rootDirs, outDir} = tsconfig.compilerOptions
const rootDirPath = rootDir || (rootDirs || [])[0]
if (!rootDirPath || !outDir) return orig
// rewrite path from ./lib/foo to ./src/foo
const lib = path.join(root, outDir) // ./lib
const src = path.join(root, rootDir) // ./src
const src = path.join(root, rootDirPath) // ./src
const relative = path.relative(lib, orig) // ./commands
const out = path.join(src, relative) // ./src/commands
// this can be a directory of commands or point to a hook file
Expand Down

0 comments on commit a6078d1

Please sign in to comment.