mirror of
https://github.com/actions/labeler.git
synced 2025-12-12 04:27:34 +00:00
Throw an error if the config is the wrong type
This commit is contained in:
@@ -130,20 +130,22 @@ async function fetchContent(
|
|||||||
function getLabelConfigMapFromObject(
|
function getLabelConfigMapFromObject(
|
||||||
configObject: any
|
configObject: any
|
||||||
): Map<string, MatchConfig[]> {
|
): Map<string, MatchConfig[]> {
|
||||||
const labelGlobs: Map<string, MatchConfig[]> = new Map();
|
const labelMap: Map<string, MatchConfig[]> = new Map();
|
||||||
for (const label in configObject) {
|
for (const label in configObject) {
|
||||||
if (typeof configObject[label] === 'string') {
|
const configOptions = configObject[label];
|
||||||
labelGlobs.set(label, [configObject[label]]);
|
if (
|
||||||
} else if (configObject[label] instanceof Array) {
|
!Array.isArray(configOptions) ||
|
||||||
labelGlobs.set(label, configObject[label]);
|
!configOptions.every(opts => typeof opts === 'object')
|
||||||
} else {
|
) {
|
||||||
throw Error(
|
throw Error(
|
||||||
`found unexpected type for label ${label} (should be string or array of globs)`
|
`found unexpected type for label ${label} (should be array of config options)`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
labelMap.set(label, configOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
return labelGlobs;
|
return labelMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toChangedFilesMatchConfig(config: any): ChangedFilesMatchConfig {
|
function toChangedFilesMatchConfig(config: any): ChangedFilesMatchConfig {
|
||||||
|
|||||||
Reference in New Issue
Block a user