feat: add label configuration fields to barcode templates and implement zero-padding support in variable replacement
Build and Push Multi-Platform Images / build-and-push (push) Successful in 27s
Build and Push Multi-Platform Images / build-and-push (push) Successful in 27s
This commit is contained in:
@@ -14,7 +14,17 @@ function escape(s: string): string {
|
||||
}
|
||||
|
||||
function applyVars(template: string, vars: Record<string, string>): string {
|
||||
return template.replace(/\{([^}]+)\}/g, (_, key) => vars[key] ?? `{${key}}`);
|
||||
return template.replace(/\{([^}]+)\}/g, (_, key: string) => {
|
||||
const colonIdx = key.indexOf(':');
|
||||
if (colonIdx !== -1) {
|
||||
const varName = key.slice(0, colonIdx);
|
||||
const width = parseInt(key.slice(colonIdx + 1), 10);
|
||||
if (!isNaN(width) && varName in vars) {
|
||||
return vars[varName].padStart(width, '0');
|
||||
}
|
||||
}
|
||||
return vars[key] ?? `{${key}}`;
|
||||
});
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
|
||||
Reference in New Issue
Block a user