Support dynamic new value creation for metadata value migration
This commit is contained in:
@@ -21,7 +21,7 @@ export interface IMetadataMigration {
|
||||
*/
|
||||
key?: string;
|
||||
oldValue: string | RegExp;
|
||||
newValue: string;
|
||||
newValue: string | ((oldValue: string) => string);
|
||||
}[];
|
||||
keys?: { oldKey: string; newKey: string }[];
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ const applyMetadataValueMigration = (meta: Metadata, migration: IMetadataMigrati
|
||||
metadataValueChanges.forEach(({ key, oldValue, newValue }) => {
|
||||
const migrateValue = (metaKey: string) => {
|
||||
if (meta[metaKey].match(oldValue)) {
|
||||
migratedMetadata[metaKey] = newValue;
|
||||
migratedMetadata[metaKey] = typeof newValue === 'function' ? newValue(meta[metaKey]) : newValue;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user