11import path from 'node:path'
22import { fsCopy } from '../utils/fs.ts'
33import { toArray } from '../utils/general.ts'
4+ import { prettyName } from '../utils/logger.ts'
45import type { ResolvedConfig } from '../config/index.ts'
56import type { Arrayable , Awaitable } from '../utils/types.ts'
67
@@ -19,18 +20,29 @@ export async function copy(options: ResolvedConfig): Promise<void> {
1920 ? await options . copy ( options )
2021 : options . copy
2122
23+ const resolved : [ from : string , to : string ] [ ] = toArray ( copy ) . map ( ( dir ) => {
24+ const from = path . resolve (
25+ options . cwd ,
26+ typeof dir === 'string' ? dir : dir . from ,
27+ )
28+ const to =
29+ typeof dir === 'string'
30+ ? path . resolve ( options . outDir , path . basename ( from ) )
31+ : path . resolve ( options . cwd , dir . to )
32+ return [ from , to ]
33+ } )
34+
35+ const name = prettyName ( options . name )
2236 await Promise . all (
23- toArray ( copy ) . map ( ( dir ) => {
24- const from = typeof dir === 'string' ? dir : dir . from
25- const to =
26- typeof dir === 'string'
27- ? path . resolve ( options . outDir , path . basename ( from ) )
28- : dir . to
29- return cp ( options . cwd , from , to )
37+ resolved . map ( ( [ from , to ] ) => {
38+ options . logger . info (
39+ name ,
40+ `Copying files from ${ path . relative ( options . cwd , from ) } to ${ path . relative (
41+ options . cwd ,
42+ to ,
43+ ) } `,
44+ )
45+ return fsCopy ( from , to )
3046 } ) ,
3147 )
3248}
33-
34- function cp ( cwd : string , from : string , to : string ) : Promise < void > {
35- return fsCopy ( path . resolve ( cwd , from ) , path . resolve ( cwd , to ) )
36- }
0 commit comments