MCPcopy
hub / github.com/htmlhint/HTMLHint / getGlobInfo

Function getGlobInfo

src/cli/htmlhint.ts:365–403  ·  view source on GitHub ↗
(target: string)

Source from the content-addressed store, hash-verified

363
364// split target to base & glob
365function getGlobInfo(target: string): {
366 base: string
367 pattern: string
368 ignore?: string
369} {
370 // fix windows sep
371 target = target.replace(/\\/g, '/')
372
373 const globInfo = parseGlob(target)
374 let base = resolve(globInfo.base)
375
376 base += /\/$/.test(base) ? '' : '/'
377
378 let pattern = globInfo.glob
379 const globPath = globInfo.path
380 const defaultGlob = '*.{htm,html}'
381
382 if (globInfo.is.glob === true) {
383 // no basename
384 if (globPath.basename === '') {
385 pattern += defaultGlob
386 }
387 } else {
388 // no basename
389 if (globPath.basename === '') {
390 pattern += `**/${defaultGlob}`
391 }
392 // detect directory
393 else if (existsSync(target) && statSync(target).isDirectory()) {
394 base += `${globPath.basename}/`
395 pattern = `**/${defaultGlob}`
396 }
397 }
398
399 return {
400 base: base,
401 pattern: pattern,
402 }
403}
404
405// search and load config
406function getConfig(

Callers 1

hintAllFilesFunction · 0.85

Calls 1

parseGlobFunction · 0.90

Tested by

no test coverage detected