diff --git a/Lib/helper.mjs b/Lib/helper.mjs index 1974dcd..c211843 100644 --- a/Lib/helper.mjs +++ b/Lib/helper.mjs @@ -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; @@ -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}`)) {