Skip to content

Commit

Permalink
Normalize path slashes for Windows (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jontem authored and blakeembrey committed Mar 21, 2017
1 parent f9fb954 commit 721641e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/index.ts
Expand Up @@ -123,7 +123,7 @@ export function parse (value: string | undefined) {
/**
* Replace backslashes with forward slashes.
*/
export function slash (value: string): string {
export function normalizeSlashes (value: string): string {
return value.replace(/\\/g, '/')
}

Expand Down Expand Up @@ -386,7 +386,7 @@ export function register (options: Options = {}): () => Register {
* Check if the filename should be ignored.
*/
function shouldIgnore (filename: string, ignore: RegExp[], service: () => Register) {
const relname = slash(filename)
const relname = normalizeSlashes(filename)

return ignore.some(x => x.test(relname))
}
Expand Down Expand Up @@ -445,14 +445,15 @@ function readConfig (compilerOptions: any, project: string | boolean | undefined
delete result.config.compilerOptions.outFile
delete result.config.compilerOptions.declarationDir

const basePath = result.path ? dirname(result.path) : cwd
const configPath = result.path && normalizeSlashes(result.path)
const basePath = configPath ? dirname(configPath) : normalizeSlashes(cwd)

if (typeof ts.parseConfigFile === 'function') {
return ts.parseConfigFile(result.config, ts.sys, basePath)
}

if (typeof ts.parseJsonConfigFileContent === 'function') {
return ts.parseJsonConfigFileContent(result.config, ts.sys, basePath, null, result.path as string)
return ts.parseJsonConfigFileContent(result.config, ts.sys, basePath, null, configPath as string)
}

throw new TypeError('Could not find a compatible `parseConfigFile` function')
Expand Down

0 comments on commit 721641e

Please sign in to comment.