Skip to content

Commit

Permalink
Merge pull request #1713 from blackflux/dev
Browse files Browse the repository at this point in the history
[Gally]: master <- dev
  • Loading branch information
simlu authored Nov 9, 2023
2 parents 2349e2e + dd5db4a commit 3fa8eb5
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/util.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import path from 'path';
import fs from 'smart-fs';
import { sync as globSync } from 'glob';

Expand Down Expand Up @@ -33,11 +34,16 @@ export const getYamlFiles = (folder) => globSync(
}
);

export const readTextFile = (filePath) => String(fs.readFileSync(filePath));
export const loadConfig = (cwd, name) => {
const configFilePathBase = path.join(fs.dirname(import.meta.url), 'conf', name);
const configFilePath = path.join(cwd, name);

export const loadConfig = (cwd, name) => readTextFile(`${fs.dirname(import.meta.url)}/conf/${name}`)
.split('\n')
// add additional config options from project
.concat(fs.existsSync(`${cwd}/${name}`) ? readTextFile(`${cwd}/${name}`).split('\n') : [])
.map((e) => e.split('#', 1)[0].trim())
.filter((e) => e !== '');
const lines = fs.smartRead(configFilePathBase);
if (fs.existsSync(configFilePath)) {
lines.push(...fs.smartRead(configFilePath));
}

return lines
.map((e) => e.split('#', 1)[0].trim())
.filter((e) => e !== '');
};

0 comments on commit 3fa8eb5

Please sign in to comment.