MCPcopy
hub / github.com/ampproject/amphtml / debug

Function debug

build-system/compile/debug-compilation-lifecycle.js:24–45  ·  view source on GitHub ↗

* Output debugging information when developing changes in this functionality. * * @param {string} lifecycle * @param {string} fullpath * @param {?string=} content * @param {Object=} sourcemap

(lifecycle, fullpath, content, sourcemap)

Source from the content-addressed store, hash-verified

22 * @param {Object=} sourcemap
23 */
24function debug(lifecycle, fullpath, content, sourcemap) {
25 if (argv.debug) {
26 if (!content) {
27 content = fs.readFileSync(fullpath, 'utf-8');
28 }
29 const sourcemapPath = `${fullpath}.map`;
30 if (!sourcemap && fs.existsSync(sourcemapPath)) {
31 sourcemap = fs.readFileSync(sourcemapPath, 'utf-8');
32 }
33 const contentsPath = tempy.writeSync(content);
34 if (sourcemap) {
35 fs.writeFileSync(
36 `${contentsPath}.map`,
37 JSON.stringify(sourcemap, null, 4)
38 );
39 }
40 fs.appendFileSync(
41 logFile,
42 `${pad(lifecycle, 20)}: ${pad(fullpath, 100)} ${contentsPath}\n`
43 );
44 }
45}
46
47/**
48 * Logs debug information.

Callers 2

buildFunction · 0.85
setupFunction · 0.85

Calls 2

stringifyMethod · 0.80
padFunction · 0.70

Tested by

no test coverage detected