Skip to content

Commit

Permalink
fix resolve-path-update-node
Browse files Browse the repository at this point in the history
  • Loading branch information
danielpza committed Aug 19, 2024
1 parent 79cd0c6 commit 7ce1546
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/utils/resolve-path-update-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ import { isURL, maybeAddRelativeLocalPrefix } from "./general-utils";
import { isModulePathsMatch } from "./ts-helpers";
import { resolveModuleName } from "./resolve-module-name";

/* ****************************************************************************************************************** */
// region: Node Updater Utility
/* ****************************************************************************************************************** */

/** Gets proper path and calls updaterFn to get the new node if it should be updated */
export function resolvePathAndUpdateNode(
context: VisitorContext,
Expand Down Expand Up @@ -69,7 +65,8 @@ export function resolvePathAndUpdateNode(
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]);
for (let match = regex.exec(trivia); match; match = regex.exec(trivia))
if (match[1]) commentTags.set(match[1], match[2]);
} catch {}
}

Expand All @@ -83,7 +80,7 @@ export function resolvePathAndUpdateNode(

function findTag(expected: string): boolean | string | undefined {
if (commentTags.has(expected)) return commentTags.get(expected) || true;
if (!jsDocTags?.length) return void 0;
if (!jsDocTags?.length) return undefined;

for (const tag of jsDocTags) {
const tagName = tag.tagName.text.toLowerCase();
Expand All @@ -103,8 +100,8 @@ export function resolvePathAndUpdateNode(
: void 0;
}
}

return undefined;
}
}
}

// endregion

0 comments on commit 7ce1546

Please sign in to comment.