Skip to content

Commit

Permalink
Fix: Make sure the purge path can be overridden entirely
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnitto authored Jan 9, 2022
1 parent e06c140 commit 5351189
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions purge.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@ const path = require("path");
const yaml = require("js-yaml");
const fs = require("fs");
const { red } = require("nanocolors");
const deepmerge = require("deepmerge");

const pipeline = readYamlFile("pipeline");
const defaults = readYamlFile("defaults", "Build/Carbon.Pipeline");
const config = deepmerge(defaults, pipeline);

function readYamlFile(file, folder) {
function readPurgePath(file, folder) {
file = `${file}.yaml`;
const filePath = folder ? path.join(folder, file) : file;
try {
return yaml.load(fs.readFileSync(path.join("./", filePath), "utf8"));
const definition = yaml.load(fs.readFileSync(path.join("./", filePath), "utf8"));
return definition?.buildDefaults?.purge;
} catch (err) {
const linebreak = () => console.log("\n");
linebreak();
Expand All @@ -23,7 +19,11 @@ function readYamlFile(file, folder) {
}
}

let purge = config.buildDefaults.purge;
let purge = readPurgePath("pipeline");
if (!purge) {
purge = readPurgePath("defaults", "Build/Carbon.Pipeline");
}

if (!Array.isArray(purge)) {
purge = [purge];
}
Expand Down

0 comments on commit 5351189

Please sign in to comment.