Skip to content

Commit

Permalink
fix windows paths + tact error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
shaharyakir committed May 9, 2024
1 parent 51c6386 commit 876b121
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/source-verifier/tact-source-verifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export class TactSourceVerifier implements SourceVerifier {
}

async verify(payload: SourceVerifyPayload): Promise<CompileResult> {
console.log(payload.sources.map((s) => s.path));
try {
// Sort by depth because we want the original (top-level) pkg file
const pkgFilePath = payload.sources
Expand All @@ -37,6 +36,23 @@ export class TactSourceVerifier implements SourceVerifier {

const pkgParsed: PackageFileFormat = JSON.parse(pkg);

// Fix windows paths (START) - tact 1.3.0 should handle this automatically
if (pkgParsed.sources) {
pkgParsed.sources = Object.fromEntries(
Object.entries(pkgParsed.sources).map(([key, value]) => [key.replace(/\\/g, "/"), value]),
);
}

try {
const parameters = JSON.parse(pkgParsed.compiler.parameters ?? "{}");
if (parameters.entrypoint) {
pkgParsed.compiler.parameters = pkgParsed.compiler.parameters?.replace(/\\/g, "/");
}
} catch (e) {
console.warn("Unable to replace windows paths in entrypoint. ", pkgParsed.compiler);
}
// Fix windows paths (END)

const compilerSettings = {
tactVersion: pkgParsed.compiler.version,
parameters: pkgParsed.compiler.parameters,
Expand All @@ -61,10 +77,10 @@ export class TactSourceVerifier implements SourceVerifier {

const v = await timeoutPromise(
verify({
pkg,
pkg: JSON.stringify(pkgParsed),
logger: {
error: output.push,
log: output.push,
error: (e) => output.push(e),
log: (e) => output.push(e),
},
}),
parseInt(process.env.COMPILE_TIMEOUT ?? "3000"),
Expand Down

0 comments on commit 876b121

Please sign in to comment.