mirror of
https://github.com/kunkunsh/kunkun.git
synced 2025-08-04 18:48:12 +00:00
fix(api): update matchPathAndScope (#229)
Translate windows style back slash to posix style slash in order for minimatch to work. https://www.npmjs.com/package/minimatch#windows
This commit is contained in:
parent
2cbe45f6d1
commit
6ffc6f1543
1 changed files with 7 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
|||
import * as pathAPI from "@tauri-apps/api/path"
|
||||
import { BaseDirectory } from "@tauri-apps/api/path"
|
||||
import { exists, mkdir } from "@tauri-apps/plugin-fs"
|
||||
import { platform } from "@tauri-apps/plugin-os"
|
||||
import { minimatch } from "minimatch"
|
||||
import type {
|
||||
FsPermissionScoped,
|
||||
|
@ -92,8 +93,12 @@ export async function matchPathAndScope(
|
|||
scope: string,
|
||||
extensionDir: string
|
||||
): Promise<boolean> {
|
||||
const translatedTarget = await translateScopeToPath(target, extensionDir)
|
||||
const translatedScope = await translateScopeToPath(scope, extensionDir)
|
||||
let translatedTarget = await translateScopeToPath(target, extensionDir)
|
||||
let translatedScope = await translateScopeToPath(scope, extensionDir)
|
||||
if (platform() === "windows") {
|
||||
translatedTarget = translatedTarget.replaceAll("\\", "/")
|
||||
translatedScope = translatedScope.replaceAll("\\", "/")
|
||||
}
|
||||
return minimatch(translatedTarget, translatedScope)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue