pantry/scripts/utils/gha.ts

20 lines
456 B
TypeScript
Raw Normal View History

2022-09-28 18:14:46 +03:00
const e = new TextEncoder()
const encode = e.encode.bind(e)
export function set_output<T>(name: string, arr: T[], separator = " ") {
const value = arr.map(escape).join(separator)
const txt = `::set-output name=${name}::${value}`
return Deno.stdout.write(encode(`${txt}\n`))
}
//TODO HTML escapes probs
function escape<T>(input: T): string {
const out = `${input}`
if (/[<>~]/.test(out)) {
2022-09-28 18:14:46 +03:00
return `"${out}"`
} else {
return out
}
}