import { parse as yamlParse } from 'yaml' ; import { BuildFile } from './build-file' ; import { parseBuildFile } from './parse-build-file' ; import { Environment } from '../executer/environment' ; export async function read ( fileName , context ) { let content ; try { content = await context . file . read ( fileName ) ; } catch ( e ) { throw new Error ( `unable to read ${ fileName }` ) ; } try { return yamlParse ( content ) ; } catch ( e ) { throw new Error ( `unable to parse ${ fileName }: ${ e . message }` ) ; } } export async function readBuildFile ( fileName , files , context ) { if ( files [ fileName ] ) { return files [ fileName ] ; } const input = await read ( fileName , context ) ; return parseBuildFile ( fileName , files , input , context ) ; }