Skip to content

Commit 0586aee

Browse files
committed
Fix --project path resolution on Windows
1 parent 0f5c5aa commit 0586aee

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

src/Emit.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import * as path from "path";
22
import * as ts from "typescript";
33
import { CompilerOptions, LuaLibImportKind } from "./CompilerOptions";
4-
import { TranspiledFile, EmitHost } from "./Transpile";
4+
import { EmitHost, TranspiledFile } from "./Transpile";
5+
import { normalizeSlashes } from "./utils";
56

67
const trimExt = (filePath: string) => filePath.slice(0, -path.extname(filePath).length);
7-
const normalizeSlashes = (filePath: string) => filePath.replace(/\\/g, "/");
88

99
export interface OutputFile {
1010
name: string;

src/tstl.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as ts from "typescript";
44
import * as tstl from ".";
55
import * as CommandLineParser from "./CommandLineParser";
66
import * as diagnosticFactories from "./diagnostics";
7+
import { normalizeSlashes } from "./utils";
78

89
function createWatchStatusReporter(options?: ts.CompilerOptions): ts.WatchStatusReporter {
910
return (ts as any).createWatchStatusReporter(ts.sys, shouldBePretty(options));
@@ -24,7 +25,7 @@ function locateConfigFile(commandLine: tstl.ParsedCommandLine): string | undefin
2425
const { project } = commandLine.options;
2526
if (!project) {
2627
if (commandLine.fileNames.length === 0) {
27-
const searchPath = path.posix.normalize(ts.sys.getCurrentDirectory());
28+
const searchPath = normalizeSlashes(ts.sys.getCurrentDirectory());
2829
return ts.findConfigFile(searchPath, ts.sys.fileExists);
2930
}
3031
return;
@@ -36,18 +37,13 @@ function locateConfigFile(commandLine: tstl.ParsedCommandLine): string | undefin
3637
return;
3738
}
3839

39-
let fileOrDirectory = path.posix.normalize(project);
40-
if (!path.isAbsolute(fileOrDirectory)) {
41-
fileOrDirectory = path.posix.join(ts.sys.getCurrentDirectory(), fileOrDirectory);
42-
}
43-
40+
const fileOrDirectory = normalizeSlashes(path.resolve(ts.sys.getCurrentDirectory(), project));
4441
if (!fileOrDirectory || ts.sys.directoryExists(fileOrDirectory)) {
4542
const configFileName = path.posix.join(fileOrDirectory, "tsconfig.json");
4643
if (ts.sys.fileExists(configFileName)) {
4744
return configFileName;
4845
} else {
4946
reportDiagnostic(diagnosticFactories.cannotFindATsconfigJsonAtTheSpecifiedDirectory(project));
50-
5147
ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
5248
}
5349
} else {

src/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const normalizeSlashes = (filePath: string) => filePath.replace(/\\/g, "/");

0 commit comments

Comments
 (0)