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

Function walkPath

src/cli/htmlhint.ts:451–491  ·  view source on GitHub ↗
(
  globInfo: { base: string; pattern: string; ignore?: string },
  callback: (filepath: string) => void,
  onFinish: () => void
)

Source from the content-addressed store, hash-verified

449
450// walk path
451function walkPath(
452 globInfo: { base: string; pattern: string; ignore?: string },
453 callback: (filepath: string) => void,
454 onFinish: () => void
455) {
456 let base: string = globInfo.base
457 const pattern = globInfo.pattern
458 const ignore: string | undefined = globInfo.ignore
459 const arrIgnores = ['**/node_modules/**']
460
461 if (ignore) {
462 ignore.split(',').forEach((pattern) => {
463 arrIgnores.push(pattern)
464 })
465 }
466
467 const walk = globStream(pattern, {
468 cwd: base,
469 dot: false,
470 ignore: arrIgnores,
471 nodir: true,
472 })
473
474 walk.on('data', (file: string) => {
475 base = base.replace(/^.\//, '')
476
477 if (sep !== '/') {
478 base = base.replace(/\//g, sep)
479 }
480
481 callback(base + file)
482 })
483
484 walk.on('end', () => {
485 onFinish()
486 })
487
488 walk.on('error', () => {
489 onFinish()
490 })
491}
492
493// hint file
494function hintFile(filepath: string, ruleset?: Ruleset) {

Callers 1

hintAllFilesFunction · 0.85

Calls 1

onMethod · 0.80

Tested by

no test coverage detected