mirror of
https://github.com/grafana/grafana.git
synced 2026-02-03 20:49:50 -05:00
* Coverage: Add some DX improvements to by codeowner script * Potential fix for code scanning alert no. 3796: Shell command built from environment values Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * Potential fix for code scanning alert no. 3797: Shell command built from environment values Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * fix package.json and yarn lock * reorder imports * fix issue for frontend-platform: exclude files in any /test/ dir * wip * add ora spinner for codeowners manifest step * cleanup --------- Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
34 lines
1 KiB
JavaScript
34 lines
1 KiB
JavaScript
const { readFile } = require('node:fs/promises');
|
|
|
|
const { CODEOWNERS_JSON_PATH: CODEOWNERS_MANIFEST_CODEOWNERS_PATH } = require('./constants.js');
|
|
|
|
let _codeownersCache = null;
|
|
|
|
module.exports = {
|
|
/**
|
|
* import the contents of the codeowners manifest JSON file, with caching
|
|
* @param {boolean} clearCache - if true, clear the cached data and reload the codeowners manifest
|
|
* @returns {Promise<Array<string>>} - list of codeowners which own at least one file in the project
|
|
*/
|
|
async getCodeowners(clearCache = false) {
|
|
if (clearCache) {
|
|
_codeownersCache = null;
|
|
}
|
|
|
|
if (_codeownersCache == null) {
|
|
try {
|
|
const codeownersJson = await readFile(CODEOWNERS_MANIFEST_CODEOWNERS_PATH, 'utf8');
|
|
_codeownersCache = JSON.parse(codeownersJson);
|
|
} catch (e) {
|
|
if (e.code === 'ENOENT') {
|
|
console.error(`Could not read ${CODEOWNERS_MANIFEST_CODEOWNERS_PATH} ...`);
|
|
} else {
|
|
console.error(e);
|
|
}
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
return _codeownersCache;
|
|
},
|
|
};
|