( map: ExistingRawSourceMap, sourcemapPath: string, sourcemapIgnoreList: (sourcePath: string, sourcemapPath: string) => boolean, logger?: Logger, )
| 159 | } |
| 160 | |
| 161 | export function applySourcemapIgnoreList( |
| 162 | map: ExistingRawSourceMap, |
| 163 | sourcemapPath: string, |
| 164 | sourcemapIgnoreList: (sourcePath: string, sourcemapPath: string) => boolean, |
| 165 | logger?: Logger, |
| 166 | ): void { |
| 167 | let { x_google_ignoreList } = map |
| 168 | if (x_google_ignoreList === undefined) { |
| 169 | x_google_ignoreList = [] |
| 170 | } |
| 171 | if (map.sources) { |
| 172 | for ( |
| 173 | let sourcesIndex = 0; |
| 174 | sourcesIndex < map.sources.length; |
| 175 | ++sourcesIndex |
| 176 | ) { |
| 177 | const sourcePath = map.sources[sourcesIndex] |
| 178 | if (!sourcePath) continue |
| 179 | |
| 180 | const ignoreList = sourcemapIgnoreList( |
| 181 | path.isAbsolute(sourcePath) |
| 182 | ? sourcePath |
| 183 | : path.resolve(path.dirname(sourcemapPath), sourcePath), |
| 184 | sourcemapPath, |
| 185 | ) |
| 186 | if (logger && typeof ignoreList !== 'boolean') { |
| 187 | logger.warn('sourcemapIgnoreList function must return a boolean.') |
| 188 | } |
| 189 | |
| 190 | if (ignoreList && !x_google_ignoreList.includes(sourcesIndex)) { |
| 191 | x_google_ignoreList.push(sourcesIndex) |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | if (x_google_ignoreList.length > 0) { |
| 196 | if (!map.x_google_ignoreList) |
| 197 | map.x_google_ignoreList = x_google_ignoreList |
| 198 | } |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | export function extractSourcemapFromFile( |
| 203 | code: string, |
no test coverage detected