Skip to content

Commit

Permalink
fix: windows path --release
Browse files Browse the repository at this point in the history
  • Loading branch information
hemengke1997 committed Feb 17, 2025
1 parent ace95a0 commit 4667cf2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
5 changes: 5 additions & 0 deletions packages/vite-plugin-istanbul-widget/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# vite-plugin-istanbul-widget

## 1.9.6
### Patch Changes

- fix: windows path

## 1.9.5
### Patch Changes

Expand Down
2 changes: 1 addition & 1 deletion packages/vite-plugin-istanbul-widget/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vite-plugin-istanbul-widget",
"version": "1.9.5",
"version": "1.9.6",
"description": "集成了 istanbul-widget 和 vite-plugin-istanbul 的vite插件",
"type": "module",
"keywords": [
Expand Down
11 changes: 7 additions & 4 deletions packages/vite-plugin-istanbul-widget/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function istanbulWidget(opts: VitePluginIstanbulWidgetOptions): any {

if (!checkPluginEnabled(enabled, checkProd)) return

let entryFile: string = entry || ''
let entryFile = entry || ''
let config: ResolvedConfig

debug('istanbulWidget options:', opts)
Expand Down Expand Up @@ -55,9 +55,10 @@ export function istanbulWidget(opts: VitePluginIstanbulWidgetOptions): any {
const files = await glob(`${file}.{ts,tsx,js,jsx}`, {
cwd: config.root,
filesOnly: true,
absolute: true,
})
if (files.length) {
entryFile = files[0]
entryFile = normalizePath(files[0])
break
}
} catch {}
Expand Down Expand Up @@ -95,10 +96,12 @@ export function istanbulWidget(opts: VitePluginIstanbulWidgetOptions): any {
if (!entryFile) return

let isEntry = false
if (entryFile.startsWith(config.root)) {
isEntry = normalizePath(id).endsWith(normalizePath(entryFile))
if (entryFile instanceof RegExp && entryFile.test(id)) {
isEntry = true
} else if (new RegExp(entryFile).test(id)) {
isEntry = true
} else if (entryFile === id) {
isEntry = true
}

if (isEntry) {
Expand Down
2 changes: 1 addition & 1 deletion packages/vite-plugin-istanbul-widget/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type VitePluginIstanbulWidgetOptions = {
*
* 默认情况自动探测 ['src/main', 'src/root', 'app/main', 'app/root']
*/
entry?: string
entry?: string | RegExp
/**
* 是否检查正式环境
* 若为true,则正式环境下禁用插件
Expand Down

0 comments on commit 4667cf2

Please sign in to comment.