Skip to content

Commit

Permalink
Merge pull request #2223 from firebase/@invertase/Extensions/firestor…
Browse files Browse the repository at this point in the history
…e-bigquery-export/issue#2087

[Bug] Fix issue #2087: Handle multiple schema files in gen-schema-vie…
  • Loading branch information
cabljac authored Dec 3, 2024
2 parents 8266204 + 718163a commit 4aae718
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 79 deletions.

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

Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,19 @@ describe("filesystem schema loading", () => {
const schemas = schema_loader_utils.readSchemas([globPattern]);
expect(Object.keys(schemas)).to.have.members(results);
});
it("should load schemas from a comma-separated list of file paths", () => {
const schemaFiles = `${schemaDir}/full-directory/schema-1.json,${schemaDir}/full-directory/schema-2.json`;
const schemas = Object.keys(schema_loader_utils.readSchemas([schemaFiles]));
expect(schemas.length).to.equal(2);
expect(schemas).to.include(
schema_loader_utils.filePathToSchemaName(
`${schemaDir}/full-directory/schema-1.json`
)
);
expect(schemas).to.include(
schema_loader_utils.filePathToSchemaName(
`${schemaDir}/full-directory/schema-2.json`
)
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ async function parseConfig(): Promise<CliConfig> {
program.outputHelp();
process.exit(1);
}

return {
projectId: program.project,
bigQueryProjectId: program.bigQueryProject,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ function resolveFilePath(filePath: string): string {

function expandGlobs(globs: string[]): string[] {
let results = [];
for (var i = 0; i < globs.length; i++) {
const globResults = glob.sync(globs[i]);
// Split any comma-separated globs into individual paths
const expandedGlobs = globs.flatMap((g) => g.split(",").map((s) => s.trim()));
for (const globPath of expandedGlobs) {
const globResults = glob.sync(globPath);
results = results.concat(globResults);
}
return results;
Expand Down
Loading

0 comments on commit 4aae718

Please sign in to comment.