source: frontend/node_modules/workbox-build/src/lib/translate-url-to-sourcemap-paths.ts

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1005 bytes
Line 
1/*
2 Copyright 2021 Google LLC
3
4 Use of this source code is governed by an MIT-style
5 license that can be found in the LICENSE file or at
6 https://opensource.org/licenses/MIT.
7*/
8
9import fse from 'fs-extra';
10import upath from 'upath';
11
12import {errors} from './errors';
13
14export function translateURLToSourcemapPaths(
15 url: string | null,
16 swSrc: string,
17 swDest: string,
18): {
19 destPath: string | undefined;
20 srcPath: string | undefined;
21 warning: string | undefined;
22} {
23 let destPath: string | undefined = undefined;
24 let srcPath: string | undefined = undefined;
25 let warning: string | undefined = undefined;
26
27 if (url && !url.startsWith('data:')) {
28 const possibleSrcPath = upath.resolve(upath.dirname(swSrc), url);
29 if (fse.existsSync(possibleSrcPath)) {
30 srcPath = possibleSrcPath;
31 destPath = upath.resolve(upath.dirname(swDest), url);
32 } else {
33 warning = `${errors['cant-find-sourcemap']} ${possibleSrcPath}`;
34 }
35 }
36
37 return {destPath, srcPath, warning};
38}
Note: See TracBrowser for help on using the repository browser.