import { emojis , files , folders } from 'shared/constants' ; import { resolve , basename , parse } from 'path' ; import { fileSystemService , debugService } from 'services' ; import { getAllFiles } from '../file-system/get-all-files' ; async param { String } portRootFolder param { String } outputFolder return { Promise < void > } example export async function copyExtraFiles ( portRootFolder , outputFolder = '' ) { const debug = debugService ( 'copy-extra-files' , parse ( portRootFolder ) . name ) ; debug ( `${ emojis . robot } copying extra files` ) ; const { copy } = fileSystemService ( ) ; const extraFilesPath = resolve ( portRootFolder , folders . extraFolder ) ; const extraFiles = await getAllFiles ( extraFilesPath ) ; const sanitizedExtraFiles = extraFiles . filter ( ( file ) => ! files . blackListedFiles . find ( ( blackListedFile ) => file . includes ( blackListedFile ) ) ) ; for ( const from of sanitizedExtraFiles ) { try { const portFolderName = basename ( portRootFolder ) ; const defaultDistPath = from . replace ( `src/ports/${ portFolderName }/extra/` , `${ folders . distFolder }/${ portFolderName }/` ) ; const providedDistPath = from . replace ( `${ resolve ( ) }/src/ports/${ portFolderName }/extra/` , `${ outputFolder }/` ) ; const distFolder = outputFolder ? parse ( providedDistPath ) . dir : parse ( defaultDistPath ) . dir ; await copy ( from , distFolder ) ; debug ( `${ emojis . shine } done!` ) ; } catch ( err ) { console . error ( err ) ; } } }