Open History to see the last commit
1import {basename} from 'node:path'
2
3export function normalizeCompilerSourcePaths(text,sourceDirectory){
4 return text.replaceAll(sourceDirectory,'/sources/quickjs-emscripten')
5}
6
7export function normalizeInspectionWrapperPaths(text,metafileInputs,stagingDirectory){
8 const stagedDirectoryName=basename(stagingDirectory)
9 const marker=`/${stagedDirectoryName}/inspection-core/`
10 const stagedInput=metafileInputs.find(input=>input.includes(marker))
11 if(!stagedInput)throw Error(`esbuild metadata did not identify the staged inspection wrapper ${stagedDirectoryName}`)
12 const stagedWrapperPath=stagedInput.slice(0,stagedInput.indexOf('/inspection-core/'))
13 const normalized=text.replaceAll(stagedWrapperPath,'/sources/quickjs-staged')
14 if(normalized===text||normalized.includes(stagedDirectoryName)){
15 throw Error('Failed to remove the temporary inspection wrapper path from the engine bundle')
16 }
17 return normalized
18}