fix to not import multiple times

This commit is contained in:
zongor 2024-05-27 19:13:13 -04:00
parent af15775e5e
commit ad00791462
1 changed files with 12 additions and 6 deletions

View File

@ -51,12 +51,12 @@ const { values } = parseArgs({
short: "S",
},
jsout: {
type: "string",
short: "j"
type: "string",
short: "j",
},
cout: {
type: "string",
short: "c"
type: "string",
short: "c",
},
},
strict: true,
@ -146,7 +146,10 @@ for (const type of Object.keys(schema)) {
set ${prop}(v) {
this._data.set(v.bytes(), ${offset});
}`;
importStatements += `import ${propType} from "./${propType}"\n\n`;
const importS = `import ${propType} from "./${propType}"\n\n`;
if (!importStatements.includes(importS)) {
importStatements += importS;
}
cData += `\n\t\t${types[propType].c} ${prop};`;
break;
@ -179,6 +182,9 @@ export default ${type}`;
`;
await Bun.write(Bun.file(values.jsout + type + ".js"), (importStatements + jsData));
await Bun.write(
Bun.file(values.jsout + type + ".js"),
importStatements + jsData
);
}
await Bun.write(Bun.file(values.cout + "types.h"), cData);