Skip to content

Instantly share code, notes, and snippets.

@jwulf
Last active February 27, 2020 17:42
Show Gist options
  • Save jwulf/60e1d53d0b38056f9acfd82e05946125 to your computer and use it in GitHub Desktop.
Save jwulf/60e1d53d0b38056f9acfd82e05946125 to your computer and use it in GitHub Desktop.
const filereader = wf => typeof wf === 'object' ? wf : read(wf)
const read = filename => fs.existsSync(filename) ?
{ buffer: fs.readFileSync(filename) } :
{ error: filename }
const outcomes = workflows.map(filereader)
const { error, buffer } = outcomes.reduce((acc, o) => o.error ?
{ error: [...acc.error, o.error], buffer: acc.buffer } :
{ error: acc.error, buffer: [...acc.buffer, o.buffer] },
{ error: [], buffer: [] })
if (error.length > 0) {
throw new Error(`Could not find files: ${error.join(', ')`})
}
deploy(buffer.map(makeRequestFromBuffer))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment