Skip to content

Commit

Permalink
Also use relative path if path starts with '..'
Browse files Browse the repository at this point in the history
  • Loading branch information
vdrg committed Dec 13, 2024
1 parent 6a7b92e commit c462db3
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions packages/world/ts/node/render-solidity/worldgen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,25 +99,26 @@ export async function worldgen({
// write to file
await formatAndWriteSolidity(systemInterface, system.interfacePath, "Generated system interface");

const systemImport = {
symbol: system.label,
path: "./" + path.relative(path.dirname(system.libraryPath), system.sourcePath),
};

const libraryImports = symbolImports.map(
({ symbol, path: importPath }): ImportDatum => ({
symbol,
path: importPath.startsWith(".")
? "./" +
path.relative(
path.dirname(system.libraryPath),
path.join(rootDir, path.dirname(system.sourcePath), importPath),
)
: importPath,
}),
);

if (config.codegen.generateSystemLibraries) {
const systemImport = {
symbol: system.label,
path: "./" + path.relative(path.dirname(system.libraryPath), system.sourcePath),
};

const libraryImports = symbolImports.map(
({ symbol, path: importPath }): ImportDatum => ({
symbol,
path:
importPath.startsWith(".") || importPath.startsWith("..")
? "./" +
path.relative(
path.dirname(system.libraryPath),
path.join(rootDir, path.dirname(system.sourcePath), importPath),
)
: importPath,
}),
);

const systemLibrary = renderSystemLibrary({
libraryName: system.libraryName,
interfaceName: system.interfaceName,
Expand Down

0 comments on commit c462db3

Please sign in to comment.