Skip to content

Commit 3fc08f9

Browse files
committed
Fix windows tests
1 parent fbb9f23 commit 3fc08f9

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/transpilation/transpilation.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { SourceNode } from "source-map";
55
import * as ts from "typescript";
66
import { CompilerOptions, isBundleEnabled, LuaTarget } from "../CompilerOptions";
77
import { getLuaLibBundle } from "../LuaLib";
8-
import { assert, cast, isNonNull, trimExtension } from "../utils";
8+
import { assert, cast, isNonNull, normalizeSlashes, trimExtension } from "../utils";
99
import { Chunk, modulesToBundleChunks, modulesToChunks } from "./chunk";
1010
import { createResolutionErrorDiagnostic } from "./diagnostics";
1111
import { buildModule, Module } from "./module";
@@ -88,7 +88,7 @@ export class Transpilation {
8888
const result = this.resolver.resolveSync({}, path.dirname(issuer), request);
8989
assert(typeof result === "string", `Invalid resolution result: ${result}`);
9090
// https://github.com/webpack/enhanced-resolve#escaping
91-
resolvedPath = result.replace(/\0#/g, "#");
91+
resolvedPath = normalizeSlashes(result.replace(/\0#/g, "#"));
9292
} catch (error) {
9393
if (!isResolveError(error)) throw error;
9494
return { error: error.message };
@@ -98,6 +98,10 @@ export class Transpilation {
9898
if (!module) {
9999
if (!resolvedPath.endsWith(".lua")) {
100100
const messageText = `Resolved source file '${resolvedPath}' is not a part of the project.`;
101+
console.log(
102+
resolvedPath,
103+
this.modules.map(m => m.request)
104+
);
101105
return { error: messageText };
102106
}
103107

test/util.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,12 @@ export abstract class TestBuilder {
256256

257257
const host: tstl.TranspilerHost = { ...ts.sys };
258258
if (!this.nativeFileSystem) {
259-
const virtualFS = Volume.fromJSON({ ...this.extraRawFiles, ...this.getSourceFiles() }, "/");
259+
const cwd = process.platform === "win32" ? `${path.parse(__dirname).root[0]}:/` : "/";
260+
const virtualFS = Volume.fromJSON({ ...this.extraRawFiles, ...this.getSourceFiles() }, cwd);
260261
host.resolutionFileSystem = virtualFS;
261-
host.getCurrentDirectory = () => "/";
262+
host.getCurrentDirectory = () => cwd;
262263
host.readFile = (fileName, encoding = "utf8") =>
263-
fileName.includes("/lualib/")
264+
/[\\/]lualib[\\/]/.test(fileName)
264265
? ts.sys.readFile(fileName, encoding)
265266
: (virtualFS.readFileSync(fileName, encoding) as string);
266267
}

0 commit comments

Comments
 (0)