mirror of
https://github.com/LemmyNet/lemmy-js-client.git
synced 2024-11-01 10:09:55 +00:00
3398af0f19
* Updating types from main. * 0.20.0-alpha.13 * 0.20.0-alpha.14 * Adding tagline http calls. * 0.20.0-alpha.15 * Regenerating types from main. - Also adding exports from other_types to node script. * 0.20.0-alpha.16 * Add list custom emojis (#360) * 0.20.0-alpha.17 --------- Co-authored-by: matc-pub <161147791+matc-pub@users.noreply.github.com>
39 lines
1 KiB
JavaScript
39 lines
1 KiB
JavaScript
const fs = require("fs/promises");
|
|
const path = require("path");
|
|
|
|
const exportRegex = /export\s+(?:enum|interface|type)\s+([A-Za-z0-9_]+)/g;
|
|
|
|
const baseExports = [
|
|
'export * from "./http";',
|
|
'export {UploadImage,UploadImageResponse,ImageFile,DeleteImage} from "./other_types";',
|
|
];
|
|
|
|
async function putTypesInIndex() {
|
|
const typeFiles = await fs.readdir(path.resolve("./src/types"));
|
|
const exports = [...baseExports];
|
|
for (const filename of typeFiles) {
|
|
const localExports = [];
|
|
const fileText = await fs.readFile(path.resolve(`./src/types/${filename}`));
|
|
for (
|
|
let match = exportRegex.exec(fileText);
|
|
match;
|
|
match = exportRegex.exec(fileText)
|
|
) {
|
|
localExports.push(match[1]);
|
|
}
|
|
|
|
const spacer = localExports.length > 1 ? "\n" : " ";
|
|
|
|
exports.push(
|
|
`export {${spacer}${localExports.join(
|
|
",\n",
|
|
)}${spacer}} from "./types/${filename.replace(/\..+/, "")}";`,
|
|
);
|
|
}
|
|
|
|
fs.writeFile(path.resolve("./src/index.ts"), exports.join("\n"), {
|
|
flag: "w",
|
|
});
|
|
}
|
|
|
|
putTypesInIndex();
|