Skip to content

Commit

Permalink
New: Add import option to file
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnitto committed Nov 19, 2024
1 parent ad82308 commit c71c4af
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Lib/helper.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const styleFiles = {};
const configFile = argv("configFile") || "pipeline.yaml";
const pipeline = readYamlFile(configFile);
const defaults = readYamlFile("defaults.yaml", "Build/Carbon.Pipeline");
const config = deepmerge(defaults, pipeline);
const config = getConfig(defaults, pipeline);

const watch = argv("watch") === true;
const production = argv("production") === true;
Expand Down Expand Up @@ -110,6 +110,21 @@ toArray(config.packages).forEach((entry) => {
}
});

function getConfig(defaults, pipeline) {
let config = deepmerge(defaults, pipeline);
if (!pipeline.import) {
return config;
}
const imports = typeof pipeline.import == "string" ? [pipeline.import] : pipeline.import;
for (const key in imports) {
const filePath = imports[key];
if (filePath) {
config = deepmerge(config, readYamlFile(filePath));
}
}
return config;
}

function argv(key) {
// Return true if the key exists and a value is defined
if (process.argv.includes(`--${key}`)) {
Expand Down

0 comments on commit c71c4af

Please sign in to comment.