Skip to content

Commit

Permalink
fix: the injector fails to terminate properly
Browse files Browse the repository at this point in the history
  • Loading branch information
gizmo-ds committed Apr 9, 2024
1 parent ab3ea0b commit f070e92
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/injector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export async function injector(code: string, funcs: InjectFunction[]): Promise<s
const filters: string[] = [...new Set(funcs.map((f) => f.type))].filter((n) =>
propertys.includes(n)
)
const nodes: Record<string, AssignmentExpression | undefined> = propertys.reduce((acc, key) => {
if (filters.length === 0) return resolve(code)
const nodes: Record<string, AssignmentExpression | undefined> = filters.reduce((acc, key) => {
acc[key] = undefined
return acc
}, {})
Expand All @@ -35,6 +36,7 @@ export async function injector(code: string, funcs: InjectFunction[]): Promise<s
const name = node.expression.left.property.name
if (!filters.includes(name)) return this.skip()
nodes[name] = node.expression
if (Object.keys(nodes).every((n) => nodes[n] !== undefined)) skip = true
if (propertys.every((n) => nodes[n] !== undefined)) skip = true
return this.skip()
}
Expand Down

0 comments on commit f070e92

Please sign in to comment.