1
0
mirror of https://github.com/locomotivemtl/locomotive-boilerplate.git synced 2026-01-15 00:55:08 +08:00

Improve asset versioning task

Improved logic for replacing the value to allow for simpler regular expression patterns. Lookbehinds and lookaheads are no longer required.
This commit is contained in:
Chauncey McAskill
2023-01-13 16:42:47 -05:00
parent b6970832a3
commit 3cd81bdb3e
2 changed files with 20 additions and 3 deletions

View File

@@ -246,7 +246,20 @@ async function handleBumpVersionWithRegExp(outfile, label, options) {
const writeStream = createWriteStream(outfile, { encoding: 'utf8' });
rl.on('line', (line) => writeStream.write(line.replace(options.key, version) + "\n"));
rl.on('line', (line) => {
const found = line.match(options.key);
if (found) {
const groups = (found.groups ?? {});
const replace = found[0].replace(
(groups.build ?? groups.version ?? found[1] ?? found[0]),
version
);
line = line.replace(found[0], replace);
}
writeStream.write(line + "\n");
});
await events.once(rl, 'close');