* 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)
| 22 | * @param {Object=} sourcemap |
| 23 | */ |
| 24 | function 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. |