Skip to content

Commit

Permalink
fix: 快速模式判断html修正
Browse files Browse the repository at this point in the history
  • Loading branch information
jaw52 committed Mar 16, 2023
1 parent c567105 commit ccf2609
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"consola": "^2.15.3",
"execa": "^7.0.0",
"fast-glob": "^3.2.12",
"is-html": "^3.0.0",
"kolorist": "^1.7.0",
"ora": "^6.1.2",
"p-limit": "^4.0.0",
Expand Down
14 changes: 14 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions src/transformStart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import slash from 'slash'
import glob from 'fast-glob'
import ora from 'ora'
import pLimit from 'p-limit'
import isHtml from 'is-html'
import { loadArgs } from './utils/loadArgs'
import { gitMv } from './utils/gitMv'
import { formatMs } from './utils/formatTime'
Expand Down Expand Up @@ -58,10 +59,7 @@ export const transformStart = async ({ scanPath, isGitMv, lang, mode }: Setting)
const source = fs.readFileSync(path, 'utf-8')

if (mode === 'fast') {
const reactRE = /[\'"]\s*react\s*[\'"]/
const htmlRE = /<(\w+)[^>]*>(.*?<\/\1>)?/

if (reactRE.test(source) && htmlRE.test(source))
if (isHtml(source))
needTransformList.push(path)
}
else {
Expand Down

0 comments on commit ccf2609

Please sign in to comment.