import * as path from 'path' ; import { writeFileAsync } from '../utils' ; import { TaskContext } from './task_context' ; export function writeToFileTask ( { roots } ) { return roots . map ( ( root ) => ( { task : async ( ) => { const fullPath = path . resolve ( process . cwd ( ) , root . config . output ) ; if ( root . mapping && Object . keys ( root . mapping . properties ) . length > 0 ) { const serializedMapping = JSON . stringify ( root . mapping , null , 2 ) . concat ( '\n' ) ; await writeFileAsync ( fullPath , serializedMapping ) ; } } , title : `Writing mapping for ${ root . config . root }` , } ) ) ; }