Skip to content

Commit b068f7f

Browse files
committed
fix(schema-compiler): skip empty YAML files
1 parent 1fc6490 commit b068f7f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/cubejs-schema-compiler/src/compiler/YamlCompiler.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,19 @@ export class YamlCompiler {
2525
}
2626

2727
public compileYamlFile(file, errorsReport, cubes, contexts, exports, asyncModules, toCompile, compiledFiles) {
28+
if (!file.content.trim()) {
29+
return;
30+
}
31+
2832
const yamlObj = YAML.load(file.content);
2933
for (const key of Object.keys(yamlObj)) {
3034
if (key === 'cubes') {
31-
yamlObj.cubes.forEach(({ name, ...cube }) => {
35+
(yamlObj.cubes || []).forEach(({ name, ...cube }) => {
3236
const transpiledFile = this.transpileAndPrepareJsFile(file, 'cube', { name, ...cube }, errorsReport);
3337
this.dataSchemaCompiler?.compileJsFile(transpiledFile, errorsReport, cubes, contexts, exports, asyncModules, toCompile, compiledFiles);
3438
});
3539
} else if (key === 'views') {
36-
yamlObj.views.forEach(({ name, ...cube }) => {
40+
(yamlObj.views || []).forEach(({ name, ...cube }) => {
3741
const transpiledFile = this.transpileAndPrepareJsFile(file, 'view', { name, ...cube }, errorsReport);
3842
this.dataSchemaCompiler?.compileJsFile(transpiledFile, errorsReport, cubes, contexts, exports, asyncModules, toCompile, compiledFiles);
3943
});

0 commit comments

Comments
 (0)