Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Commit

Permalink
update import writer
Browse files Browse the repository at this point in the history
  • Loading branch information
AlejandroLabourdette committed Feb 15, 2023
1 parent ba9c2a7 commit cc406a8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/cairoWriter/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ export function writeImports(imports: Map<string, Set<string>>): string {
);
}
return [...imports.entries()]
.map(
([location, importedSymbols]) =>
`from ${location} import ${[...importedSymbols.keys()].join(', ')}`,
)
.map(([location, importedSymbols]) => {
const toImport = [...importedSymbols.keys()];
const toImportFormatted =
toImport.length === 1 ? toImport[0] : '{' + toImport.join(', ') + '}';
return `use ${location.replaceAll('.', '::')}::${toImportFormatted};`;
})
.join('\n');
}

Expand Down

0 comments on commit cc406a8

Please sign in to comment.