- introduce new API allowing to write changelog directly to result file
- introduce test case for writing a file
This commit is contained in:
@@ -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}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user