import { WorkNode } from '../planner/work-node' ; import { Environment } from '../executer/environment' ; export async function moveFiles ( node , context , folder ) { const foldersToCopy = [ ] ; const addFolder = async ( from , to ) => { if ( ! ( await context . file . exists ( from ) ) ) { return ; } if ( foldersToCopy . some ( ( f ) => f . from === from && f . to === to ) ) { return ; } foldersToCopy . push ( { from , to } ) ; } ; for ( const { from , to } of folder ( ) ) { await addFolder ( from , to ) ; } for ( const folder of foldersToCopy ) { if ( await context . file . exists ( folder . to ) ) { await context . file . remove ( folder . to ) ; } node . status . console . write ( 'internal' , 'debug' , `copy ${ folder . from } to ${ folder . to }` ) ; await context . file . copy ( folder . from , folder . to ) ; } }