import { each } from '../util' ; import * as globs from 'globby' ; import { resolve } from 'path' ; import { NexeCompiler } from '../compiler' ; export default async function resource ( compiler , next ) { const { cwd , resources } = compiler . options ; if ( ! resources . length ) { return next ( ) ; } const step = compiler . log . step ( 'Bundling Resources...' ) ; let count = 0 ; const resourcesWithForwardSlashes = resources . map ( ( r ) => r . replace ( /\\/g , '/' ) ) ; await each ( globs ( resourcesWithForwardSlashes , { cwd , onlyFiles : true } ) , async ( file ) => { count ++ ; step . log ( `Including file: ${ file }` ) ; await compiler . addResource ( resolve ( cwd , file ) ) ; } ) ; step . log ( `Included ${ count } file(s)` ) ; return next ( ) ; }