* 读取文件内容 * @param {string} filePath 文件路径 * @param {string} encoding 编码方式,默认为 utf-8 * @returns {Promise } 文件内容
(filePath, encoding = 'utf-8')
| 56 | * @param {any} data 要写入的数据 |
| 57 | * @returns {Promise<void>} |
| 58 | */ |
| 59 | async writeFile(directory, filename, data) { |
| 60 | try { |
| 61 | const outputDir = path.join(global.paths.output, 'assets', directory); |
| 62 | await this.ensureDirectoryExists(outputDir); |
| 63 | |
| 64 | const outputPath = path.join(outputDir, filename); |
| 65 | |
| 66 | let content; |
| 67 | if (typeof data === 'object' && data !== null) { |
| 68 | content = safeJsonStringify(data, 2); |
no outgoing calls
no test coverage detected