Skip to content

Commit

Permalink
Check template for codeblocks exists or not before trying to generate
Browse files Browse the repository at this point in the history
  • Loading branch information
HaseenaSainul committed Jan 23, 2024
1 parent 651c8d6 commit 5a319d7
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/macrofier/engine.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,22 @@ const makeProviderMethod = x => x.name["onRequest".length].toLowerCase() + x.nam
//import { default as platform } from '../Platform/defaults'
const generateAggregateMacros = (openrpc, modules, templates, library) => Object.values(modules)
.reduce((acc, module) => {
acc.exports += insertMacros(getTemplate('/codeblocks/export', templates) + '\n', generateMacros(module, templates))
acc.mockImports += insertMacros(getTemplate('/codeblocks/mock-import', templates) + '\n', generateMacros(module, templates))
acc.mockObjects += insertMacros(getTemplate('/codeblocks/mock-parameter', templates) + '\n', generateMacros(module, templates))

let template = getTemplate('/codeblocks/export', templates)
if (template) {
acc.exports += insertMacros(template + '\n', generateMacros(module, templates))
}

template = getTemplate('/codeblocks/mock-import', templates)
if (template) {
acc.mockImports += insertMacros(template + '\n', generateMacros(module, templates))
}

template = getTemplate('/codeblocks/mock-parameter', templates)
if (template) {
acc.mockObjects += insertMacros(template + '\n', generateMacros(module, templates))
}

return acc
}, {
exports: '',
Expand Down

0 comments on commit 5a319d7

Please sign in to comment.