Skip to content

Commit cb55122

Browse files
committed
chore: fix build script error on windows
[skip ci]
1 parent cfe9995 commit cb55122

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

infra/compiler/src/license.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import fss from 'node:fs'
22
import path from 'node:path'
3+
import { fileURLToPath, pathToFileURL } from 'node:url'
34

45
import chalk from 'chalk'
56
import { fdir } from 'fdir'
@@ -41,12 +42,13 @@ export function checkLicense(pkgPath: string, meta: any) {
4142

4243
for (const input of inputs) {
4344
if (input.match(/node_modules/)) {
44-
const match = Array.from(input.matchAll(/node_modules\/((@[^/]+\/)?[^/]+)/g))
45+
const inputUrl = pathToFileURL(input).href
46+
const match = Array.from(inputUrl.matchAll(/node_modules\/((@[^/]+\/)?[^/]+)/g))
4547

46-
const relativePath = input.substring(0, match[match.length - 1].index)
48+
const relativePath = inputUrl.substring(0, match[match.length - 1].index)
4749
const absEntryPoint = path.resolve(path.dirname(pkgPath), input)
48-
const absPackageRoot = path.resolve(path.dirname(pkgPath), relativePath)
49-
const maxDepth = absEntryPoint.split(path.posix.sep).length - absPackageRoot.split(path.posix.sep).length
50+
const absPackageRoot = path.resolve(path.dirname(pkgPath), fileURLToPath(relativePath))
51+
const maxDepth = absEntryPoint.split(path.sep).length - absPackageRoot.split(path.sep).length
5052
checker.findLicense(absEntryPoint, maxDepth)
5153
}
5254
}

0 commit comments

Comments
 (0)