2020-09-23 15:19:20 +00:00
|
|
|
// For internal use, subject to change.
|
|
|
|
|
|
|
|
// We use any as a valid input type
|
|
|
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
|
|
|
|
|
|
import * as fs from 'fs'
|
|
|
|
import * as os from 'os'
|
2021-07-13 21:05:23 +00:00
|
|
|
import {toCommandValue} from './internal-utils'
|
2020-09-23 15:19:20 +00:00
|
|
|
|
|
|
|
export function issueCommand(command: string, message: any): void {
|
|
|
|
const filePath = process.env[`GITHUB_${command}`]
|
|
|
|
if (!filePath) {
|
|
|
|
throw new Error(
|
|
|
|
`Unable to find environment variable for file command ${command}`
|
|
|
|
)
|
|
|
|
}
|
|
|
|
if (!fs.existsSync(filePath)) {
|
|
|
|
throw new Error(`Missing file at path: ${filePath}`)
|
|
|
|
}
|
|
|
|
|
|
|
|
fs.appendFileSync(filePath, `${toCommandValue(message)}${os.EOL}`, {
|
|
|
|
encoding: 'utf8'
|
|
|
|
})
|
|
|
|
}
|