expand method
Replaces DPK_PACKAGE_PATH, DPK_PACKAGE_NAME, and
DPK_PACKAGE_VERSION in text, written bare, with $, or with ${}.
Implementation
String expand(String text) {
var result = text;
for (final (name, value) in [
('DPK_PACKAGE_PATH', packagePath),
('DPK_PACKAGE_NAME', packageName),
('DPK_PACKAGE_VERSION', packageVersion),
]) {
if (value == null) {
continue;
}
result = result
.replaceAll('\${$name}', value)
.replaceAll('\$$name', value)
.replaceAll(name, value);
}
return result;
}