Update object assignment in toChangedFilesMatchConfig

This commit is contained in:
Josh Dales
2023-03-20 17:22:19 -04:00
parent 64ce5e9235
commit cc1e02580b

View File

@@ -61,16 +61,22 @@ export function toChangedFilesMatchConfig(
} else {
// If it is not an array of strings then it should be array of further config options
// so assign them to our `changedFilesMatchConfig`
Object.assign(
changedFilesMatchConfig.changedFiles,
...changedFilesConfig
changedFilesMatchConfig.changedFiles = changedFilesConfig.reduce(
(updatedMatchConfig, configValue) => {
if (!configValue) {
return updatedMatchConfig;
}
Object.entries(configValue).forEach(([key, value]) => {
if (key === 'any' || key === 'all') {
updatedMatchConfig[key] = Array.isArray(value) ? value : [value];
}
});
return updatedMatchConfig;
},
{}
);
Object.keys(changedFilesMatchConfig.changedFiles).forEach(key => {
const value = changedFilesMatchConfig.changedFiles[key];
changedFilesMatchConfig.changedFiles[key] = Array.isArray(value)
? value
: [value];
});
}
}