File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import fss from 'node:fs'
22import path from 'node:path'
3+ import { fileURLToPath , pathToFileURL } from 'node:url'
34
45import chalk from 'chalk'
56import { 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 ( / n o d e _ m o d u l e s / ) ) {
44- const match = Array . from ( input . matchAll ( / n o d e _ m o d u l e s \/ ( ( @ [ ^ / ] + \/ ) ? [ ^ / ] + ) / g) )
45+ const inputUrl = pathToFileURL ( input ) . href
46+ const match = Array . from ( inputUrl . matchAll ( / n o d e _ m o d u l e s \/ ( ( @ [ ^ / ] + \/ ) ? [ ^ / ] + ) / 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 }
You can’t perform that action at this time.
0 commit comments