Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 11x 11x 11x 11x 11x 11x 1x 1x 10x 10x 10x 11x 11x | import type { SourceFile } from "ts-morph"; import type { CliOptions } from "../../types/cli-options"; import { log } from "@clack/prompts"; /** * Saves the changes to a source file. If the `dryRun` option is set, the changes will be logged to the console instead. * @param sourceFile The source file to save. * @param cliOptions The CLI options. * @returns A promise that resolves the full text of the source file after saving. */ export async function saveFileChanges( sourceFile: SourceFile, cliOptions: CliOptions, ): Promise<string> { sourceFile.formatText(); if (cliOptions.dryRun) { log.info("[Dry Run] Writing changes to: " + sourceFile.getFilePath()); log.info(sourceFile.getFullText()); } else { await sourceFile.save(); } return sourceFile.getFullText(); } |