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

Function formatSourcemapForSnapshot

playground/test-utils.ts:410–430  ·  view source on GitHub ↗
(
  map: any,
  code: string,
  withoutContent = false,
)

Source from the content-addressed store, hash-verified

408}
409
410export const formatSourcemapForSnapshot = (
411 map: any,
412 code: string,
413 withoutContent = false,
414): any => {
415 const root = normalizePath(testDir)
416 const m = { ...map }
417 delete m.file
418 if (m.names && m.names.length === 0) {
419 delete m.names
420 }
421 if (m.debugId) {
422 m.debugId = '00000000-0000-0000-0000-000000000000'
423 }
424 m.sources = m.sources.map((source) => source.replace(root, '/root'))
425 if (m.sourceRoot) {
426 m.sourceRoot = m.sourceRoot.replace(root, '/root')
427 }
428 const c = removeComments(code.replace(/\?v=[\da-f]{8}/g, '?v=00000000'))
429 return { map: m, code: c, [sourcemapSnapshot]: { withoutContent } }
430}
431
432// helper function to kill process, uses taskkill on windows to ensure child process is killed too
433export async function killProcess(

Callers 4

Calls 1

normalizePathFunction · 0.90

Tested by

no test coverage detected