MCPcopy Index your code
hub / github.com/ionic-team/capacitor / walkDirectory

Function walkDirectory

cli/src/tasks/sourcemaps.ts:7–27  ·  view source on GitHub ↗
(dirPath: string)

Source from the content-addressed store, hash-verified

5import { logger } from '../log';
6
7function walkDirectory(dirPath: string) {
8 const files = readdirSync(dirPath);
9 files.forEach((file) => {
10 const targetFile = join(dirPath, file);
11 if (existsSync(targetFile) && lstatSync(targetFile).isDirectory()) {
12 walkDirectory(targetFile);
13 } else {
14 const mapFile = join(dirPath, `${file}.map`);
15 if ((extname(file) === '.js' || extname(file) === '.css') && existsSync(mapFile)) {
16 const bufMap = readFileSync(mapFile).toString('base64');
17 const bufFile = readFileSync(targetFile, 'utf8');
18 const result = bufFile.replace(
19 `sourceMappingURL=${file}.map`,
20 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + bufMap,
21 );
22 writeFileSync(targetFile, result);
23 unlinkSync(mapFile);
24 }
25 }
26 });
27}
28
29export async function inlineSourceMaps(config: Config, platformName: string): Promise<void> {
30 let buildDir = '';

Callers 1

inlineSourceMapsFunction · 0.85

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected