MCPcopy
hub / github.com/vitejs/vite / ensureWatchedFile

Function ensureWatchedFile

packages/vite/src/node/utils.ts:738–754  ·  view source on GitHub ↗
(
  watcher: FSWatcher,
  file: string | null,
  root: string,
)

Source from the content-addressed store, hash-verified

736}
737
738export function ensureWatchedFile(
739 watcher: FSWatcher,
740 file: string | null,
741 root: string,
742): void {
743 if (
744 file &&
745 // only need to watch if out of root
746 !file.startsWith(withTrailingSlash(root)) &&
747 // some rollup plugins use null bytes for private resolved Ids
748 !file.includes('\0') &&
749 fs.existsSync(file)
750 ) {
751 // resolve file to normalized system path
752 watcher.add(path.resolve(file))
753 }
754}
755
756interface ImageCandidate {
757 url: string

Callers 5

addWatchFileMethod · 0.90
loadAndTransformFunction · 0.90
devHtmlHookFunction · 0.90
transformWithOxcFunction · 0.90
transformWithEsbuildFunction · 0.90

Calls 3

withTrailingSlashFunction · 0.90
addMethod · 0.80
resolveMethod · 0.65

Tested by

no test coverage detected