Skip to content

Commit

Permalink
refactor: (getStatementTags) Avoid unnecessary TS debugger statement …
Browse files Browse the repository at this point in the history
…invocations (#180)

* getStatementTags | Avoid unnecessary ts debugger statements invocation

* format
  • Loading branch information
shlomo-artlist committed Feb 18, 2024
1 parent c79f87e commit 0bb558e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/utils/resolve-path-update-node.ts
Expand Up @@ -66,12 +66,14 @@ export function resolvePathAndUpdateNode(
} catch {}

const commentTags = new Map<string, string | undefined>();
try {
const trivia = targetNode.getFullText(sourceFile).slice(0, targetNode.getLeadingTriviaWidth(sourceFile));
const regex = /^\s*\/\/\/?\s*@(transform-path|no-transform-path)(?:[^\S\r\n](.+?))?$/gim;
if (targetNode.pos >= 0) {
try {
const trivia = targetNode.getFullText(sourceFile).slice(0, targetNode.getLeadingTriviaWidth(sourceFile));
const regex = /^\s*\/\/\/?\s*@(transform-path|no-transform-path)(?:[^\S\r\n](.+?))?$/gim;

for (let match = regex.exec(trivia); match; match = regex.exec(trivia)) commentTags.set(match[1], match[2]);
} catch {}
for (let match = regex.exec(trivia); match; match = regex.exec(trivia)) commentTags.set(match[1], match[2]);
} catch {}
}

const overridePath = findTag("transform-path");
const shouldSkip = findTag("no-transform-path");
Expand Down

0 comments on commit 0bb558e

Please sign in to comment.