Skip to content

Commit

Permalink
Fix build script to generate .ts files
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysbalevicius committed May 30, 2024
1 parent ff8e9d6 commit df1d7d7
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 11 deletions.
58 changes: 50 additions & 8 deletions V3Frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions V3Frontend/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ const exec = command =>
await exec(`npx buf generate ..`);

// Generate export definitions
const pbIndex = glob.sync(`${SCHEMA_ROOT_DIR}/**/*_pb.js`)
const pbIndex = glob.sync(`${SCHEMA_ROOT_DIR}/**/*_pb.ts`)
.reduce((map, pb) =>
{
const [_, pathname] = pb.split(`${SCHEMA_ROOT_DIR}/`);
const components = pathname.split('/');
const [exportName] = components.at(-1).split('.js');
const [exportName] = components.at(-1).split('.ts');
const exportPath = `export * from './${exportName}';`;
const exportDir = components.slice(0, -1).join('/');

Expand All @@ -43,7 +43,7 @@ const exec = command =>
for (const dir in pbIndex)
{
fs.writeFileSync(
`${SCHEMA_ROOT_DIR}/${dir}/index.js`,
`${SCHEMA_ROOT_DIR}/${dir}/index.ts`,
`${pbIndex[dir].join('\n')}\n`
);
}
Expand Down

0 comments on commit df1d7d7

Please sign in to comment.