Skip to content

Commit

Permalink
fix: code match regexp (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
SadWood authored Sep 2, 2021
1 parent fe50fc5 commit c014083
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion examples/vite-vue3/components.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// generated by unplugin-vue-components
// read more https://github.com/vuejs/vue-next/pull/3399
// We suggest you to commit this file into source control
// Read more: https://github.com/vuejs/vue-next/pull/3399

declare module 'vue' {
export interface GlobalComponents {
Expand Down
2 changes: 1 addition & 1 deletion src/core/declaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { notNullish, slash } from '@antfu/utils'
import { Context } from './context'

export function parseDeclaration(code: string): Record<string, string> {
return Object.fromEntries(Array.from(code.matchAll(/\s+['"]?(.+?)['"]?:\s(.+?)\n/g)).map(i => [i[1], i[2]]))
return Object.fromEntries(Array.from(code.matchAll(/(?<!\/\/)\s+\s+['"]?(.+?)['"]?:\s(.+?)\n/g)).map(i => [i[1], i[2]]))
}

export async function generateDeclaration(ctx: Context, root: string, filepath: string) {
Expand Down

0 comments on commit c014083

Please sign in to comment.