Skip to content

Commit

Permalink
Minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Sep 6, 2022
1 parent 22722da commit c1ef12c
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions scripts/build/modify-typescript-module.mjs
Expand Up @@ -19,13 +19,15 @@ const SUBMODULE_END = escapeStringRegexp("})(ts || (ts = {}));");

function getSubmodules(text, testFunction) {
const regexp = new RegExp(
"(?<=\n)" +
`(?<before>${SUBMODULE_START})` +
"(?=\n)" +
"(?<text>.*?)" +
"(?<=\n)" +
`(?<after>${SUBMODULE_END})` +
[
"(?<=\n)",
`(?<before>${SUBMODULE_START})`,
"(?=\n)",
"(?<text>.*?)",
"(?<=\n)",
`(?<after>${SUBMODULE_END})`,
"(?=\n)",
].join(""),
"gsu"
);

Expand Down Expand Up @@ -80,12 +82,16 @@ function removeMultipleSubmodules(text, testFunction) {

function replaceAlignedCode(text, { start, end, replacement = "" }) {
const regexp = new RegExp(
"(?<=\n)(?<indentString>\\s*)" +
escapeStringRegexp(start) +
".*?" +
"(?<=\n)\\k<indentString>" +
escapeStringRegexp(end) +
[
"(?<=\n)",
"(?<indentString>\\s*)",
escapeStringRegexp(start),
".*?",
"(?<=\n)",
"\\k<indentString>",
escapeStringRegexp(end),
"(?=\n)",
].join(""),
"gsu"
);

Expand Down

0 comments on commit c1ef12c

Please sign in to comment.