Skip to content

Commit

Permalink
fix: root path issue
Browse files Browse the repository at this point in the history
  • Loading branch information
yorkyao committed Nov 2, 2018
1 parent 292dacb commit 994488c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions spec/result.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
src/tsconfig.ts:35:31: config
src/core.ts:30:45: intrinsicName
src/core.ts:39:159: intrinsicName
src/core.ts:31:45: intrinsicName
src/core.ts:40:159: intrinsicName
src/index.ts:15:37: v
src/index.ts:15:47: version
src/index.ts:21:24: suppressError
Expand All @@ -11,5 +11,5 @@ src/index.ts:23:106: debug
src/index.ts:44:4: error
src/index.ts:45:7: error
src/index.ts:48:17: error
3167 / 3180 99.59%
3178 / 3191 99.59%
type-coverage success.
5 changes: 3 additions & 2 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as path from 'path'
import { getTsConfigFilePath, getTsConfig, getRootNames } from './tsconfig'

// tslint:disable-next-line:no-big-function
export async function lint(project: string, detail: boolean, debug: boolean, files?: string[]) {
export async function lint(project: string, detail: boolean, debug: boolean, rootPath: string, files?: string[]) {
const { configFilePath, dirname } = getTsConfigFilePath(project)
const config = getTsConfig(configFilePath, dirname)

Expand All @@ -13,7 +13,8 @@ export async function lint(project: string, detail: boolean, debug: boolean, fil
throw errors
}

const rootNames = await getRootNames(config, dirname)
let rootNames = await getRootNames(config, dirname)
rootNames = rootNames.map((r) => path.resolve(rootPath, r))

const program = ts.createProgram(rootNames, compilerOptions)
const checker = program.getTypeChecker()
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async function executeCommandLine() {

suppressError = argv.suppressError

const { correctCount, totalCount, anys } = await lint(argv.p || argv.project || '.', argv.detail, argv.debug)
const { correctCount, totalCount, anys } = await lint(argv.p || argv.project || '.', argv.detail, argv.debug, process.cwd())
for (const { file, line, character, text } of anys) {
console.log(`${file}:${line + 1}:${character + 1}: ${text}`)
}
Expand Down

0 comments on commit 994488c

Please sign in to comment.