Skip to content

Commit

Permalink
fix: raise error when a component/prefab doesn't return anything (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephankaag authored and larshisken committed Jan 10, 2020
1 parent a0f2635 commit 3bf433d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/bb-components-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ const readComponents: () => Promise<
try {
const code: string = await readFile(`${srcDir}/${file}`, 'utf-8');
// eslint-disable-next-line no-new-func
return Function(`return ${transpile(code)}`)();
const transpiledFunction = Function(`return ${transpile(code)}`)()
if (!transpiledFunction) throw(new Error('Component doesn\'t return anything'));
return transpiledFunction
} catch (error) {
error.file = file;
throw error;
Expand All @@ -75,7 +77,9 @@ const readPrefabs: () => Promise<Prefab[]> = async (): Promise<Prefab[]> => {
try {
const code: string = await readFile(`${srcDir}/${file}`, 'utf-8');
// eslint-disable-next-line no-new-func
return Function(`return ${code}`)();
const transpiledFunction = Function(`return ${code}`)()
if (!transpiledFunction) throw(new Error('Prefab doesn\'t return anything'));
return transpiledFunction
} catch (error) {
error.file = file;
throw error;
Expand Down

0 comments on commit 3bf433d

Please sign in to comment.