- introduce new API allowing to write changelog directly to result file

- introduce test case for writing a file
This commit is contained in:
Mike Penz
2020-12-30 17:49:41 +01:00
parent 9a0355af98
commit a463f188c1
7 changed files with 13179 additions and 5 deletions
+19
View File
@@ -111,3 +111,22 @@ export function directoryExistsSync(
throw new Error(`Directory '${inputPath}' does not exist`)
}
/**
* Writes the changelog to the given the file
*/
export function writeOutput(
githubWorkspacePath: string,
outputFile: string,
changelog: string | null
): void {
if (outputFile && changelog) {
const outputPath = path.resolve(githubWorkspacePath, outputFile)
core.debug(`outputPath = '${outputPath}'`)
try {
fs.writeFileSync(outputPath, changelog)
} catch (error) {
core.warning(`⚠️ Could not write the file to disk - ${error.message}`)
}
}
}