11import { resolve } from 'node:path' ;
2+ import { mkdir } from 'node:fs/promises' ;
23
34import test from 'ava' ;
4- import { copy , ensureDir } from 'fs-extra' ;
55import { isPlainObject , sortBy } from 'lodash-es' ;
66import tempy from 'tempy' ;
7+ import cpy from 'cpy' ;
78
89import globAssets from '../lib/glob-assets.js' ;
910
@@ -13,31 +14,31 @@ const fixtures = 'test/fixtures/files';
1314
1415test ( 'Retrieve file from single path' , async ( t ) => {
1516 const cwd = tempy . directory ( ) ;
16- await copy ( fixtures , cwd ) ;
17+ await cpy ( fixtures , cwd , { dot : true } ) ;
1718 const globbedAssets = await globAssets ( { cwd} , [ 'upload.txt' ] ) ;
1819
1920 t . deepEqual ( globbedAssets , [ 'upload.txt' ] ) ;
2021} ) ;
2122
2223test ( 'Retrieve multiple files from path' , async ( t ) => {
2324 const cwd = tempy . directory ( ) ;
24- await copy ( fixtures , cwd ) ;
25+ await cpy ( fixtures , cwd , { dot : true } ) ;
2526 const globbedAssets = await globAssets ( { cwd} , [ 'upload.txt' , 'upload_other.txt' ] ) ;
2627
2728 t . deepEqual ( sortAssets ( globbedAssets ) , sortAssets ( [ 'upload_other.txt' , 'upload.txt' ] ) ) ;
2829} ) ;
2930
3031test ( 'Include missing files as defined, using Object definition' , async ( t ) => {
3132 const cwd = tempy . directory ( ) ;
32- await copy ( fixtures , cwd ) ;
33+ await cpy ( fixtures , cwd , { dot : true } ) ;
3334 const globbedAssets = await globAssets ( { cwd} , [ 'upload.txt' , { path : 'miss*.txt' , label : 'Missing' } ] ) ;
3435
3536 t . deepEqual ( sortAssets ( globbedAssets ) , sortAssets ( [ 'upload.txt' , { path : 'miss*.txt' , label : 'Missing' } ] ) ) ;
3637} ) ;
3738
3839test ( 'Retrieve multiple files from Object' , async ( t ) => {
3940 const cwd = tempy . directory ( ) ;
40- await copy ( fixtures , cwd ) ;
41+ await cpy ( fixtures , cwd , { dot : true } ) ;
4142 const globbedAssets = await globAssets ( { cwd} , [
4243 { path : 'upload.txt' , name : 'upload_name' , label : 'Upload label' } ,
4344 'upload_other.txt' ,
@@ -51,7 +52,7 @@ test('Retrieve multiple files from Object', async (t) => {
5152
5253test ( 'Retrieve multiple files without duplicates' , async ( t ) => {
5354 const cwd = tempy . directory ( ) ;
54- await copy ( fixtures , cwd ) ;
55+ await cpy ( fixtures , cwd , { dot : true } ) ;
5556 const globbedAssets = await globAssets ( { cwd} , [
5657 'upload_other.txt' ,
5758 'upload.txt' ,
@@ -66,7 +67,7 @@ test('Retrieve multiple files without duplicates', async (t) => {
6667
6768test ( 'Favor Object over String values when removing duplicates' , async ( t ) => {
6869 const cwd = tempy . directory ( ) ;
69- await copy ( fixtures , cwd ) ;
70+ await cpy ( fixtures , cwd , { dot : true } ) ;
7071 const globbedAssets = await globAssets ( { cwd} , [
7172 'upload_other.txt' ,
7273 'upload.txt' ,
@@ -88,47 +89,47 @@ test('Favor Object over String values when removing duplicates', async (t) => {
8889
8990test ( 'Retrieve file from single glob' , async ( t ) => {
9091 const cwd = tempy . directory ( ) ;
91- await copy ( fixtures , cwd ) ;
92+ await cpy ( fixtures , cwd , { dot : true } ) ;
9293 const globbedAssets = await globAssets ( { cwd} , [ 'upload.*' ] ) ;
9394
9495 t . deepEqual ( globbedAssets , [ 'upload.txt' ] ) ;
9596} ) ;
9697
9798test ( 'Retrieve multiple files from single glob' , async ( t ) => {
9899 const cwd = tempy . directory ( ) ;
99- await copy ( fixtures , cwd ) ;
100+ await cpy ( fixtures , cwd , { dot : true } ) ;
100101 const globbedAssets = await globAssets ( { cwd} , [ '*.txt' ] ) ;
101102
102103 t . deepEqual ( sortAssets ( globbedAssets ) , sortAssets ( [ 'upload_other.txt' , 'upload.txt' ] ) ) ;
103104} ) ;
104105
105106test ( 'Accept glob array with one value' , async ( t ) => {
106107 const cwd = tempy . directory ( ) ;
107- await copy ( fixtures , cwd ) ;
108+ await cpy ( fixtures , cwd , { dot : true } ) ;
108109 const globbedAssets = await globAssets ( { cwd} , [ [ '*load.txt' ] , [ '*_other.txt' ] ] ) ;
109110
110111 t . deepEqual ( sortAssets ( globbedAssets ) , sortAssets ( [ 'upload_other.txt' , 'upload.txt' ] ) ) ;
111112} ) ;
112113
113114test ( 'Include globs that resolve to no files as defined' , async ( t ) => {
114115 const cwd = tempy . directory ( ) ;
115- await copy ( fixtures , cwd ) ;
116+ await cpy ( fixtures , cwd , { dot : true } ) ;
116117 const globbedAssets = await globAssets ( { cwd} , [ [ 'upload.txt' , '!upload.txt' ] ] ) ;
117118
118119 t . deepEqual ( sortAssets ( globbedAssets ) , sortAssets ( [ '!upload.txt' , 'upload.txt' ] ) ) ;
119120} ) ;
120121
121122test ( 'Accept glob array with one value for missing files' , async ( t ) => {
122123 const cwd = tempy . directory ( ) ;
123- await copy ( fixtures , cwd ) ;
124+ await cpy ( fixtures , cwd , { dot : true } ) ;
124125 const globbedAssets = await globAssets ( { cwd} , [ [ '*missing.txt' ] , [ '*_other.txt' ] ] ) ;
125126
126127 t . deepEqual ( sortAssets ( globbedAssets ) , sortAssets ( [ 'upload_other.txt' , '*missing.txt' ] ) ) ;
127128} ) ;
128129
129130test ( 'Replace name by filename for Object that match multiple files' , async ( t ) => {
130131 const cwd = tempy . directory ( ) ;
131- await copy ( fixtures , cwd ) ;
132+ await cpy ( fixtures , cwd , { dot : true } ) ;
132133 const globbedAssets = await globAssets ( { cwd} , [ { path : '*.txt' , name : 'upload_name' , label : 'Upload label' } ] ) ;
133134
134135 t . deepEqual (
@@ -142,56 +143,56 @@ test('Replace name by filename for Object that match multiple files', async (t)
142143
143144test ( 'Include dotfiles' , async ( t ) => {
144145 const cwd = tempy . directory ( ) ;
145- await copy ( fixtures , cwd ) ;
146+ await cpy ( fixtures , cwd , { dot : true } ) ;
146147 const globbedAssets = await globAssets ( { cwd} , [ '.dot*' ] ) ;
147148
148149 t . deepEqual ( globbedAssets , [ '.dotfile' ] ) ;
149150} ) ;
150151
151152test ( 'Ingnore single negated glob' , async ( t ) => {
152153 const cwd = tempy . directory ( ) ;
153- await copy ( fixtures , cwd ) ;
154+ await cpy ( fixtures , cwd , { dot : true } ) ;
154155 const globbedAssets = await globAssets ( { cwd} , [ '!*.txt' ] ) ;
155156
156157 t . deepEqual ( globbedAssets , [ ] ) ;
157158} ) ;
158159
159160test ( 'Ingnore single negated glob in Object' , async ( t ) => {
160161 const cwd = tempy . directory ( ) ;
161- await copy ( fixtures , cwd ) ;
162+ await cpy ( fixtures , cwd , { dot : true } ) ;
162163 const globbedAssets = await globAssets ( { cwd} , [ { path : '!*.txt' } ] ) ;
163164
164165 t . deepEqual ( globbedAssets , [ ] ) ;
165166} ) ;
166167
167168test ( 'Accept negated globs' , async ( t ) => {
168169 const cwd = tempy . directory ( ) ;
169- await copy ( fixtures , cwd ) ;
170+ await cpy ( fixtures , cwd , { dot : true } ) ;
170171 const globbedAssets = await globAssets ( { cwd} , [ [ '*.txt' , '!**/*_other.txt' ] ] ) ;
171172
172173 t . deepEqual ( globbedAssets , [ 'upload.txt' ] ) ;
173174} ) ;
174175
175176test ( 'Expand directories' , async ( t ) => {
176177 const cwd = tempy . directory ( ) ;
177- await copy ( fixtures , resolve ( cwd , 'dir' ) ) ;
178+ await cpy ( fixtures , resolve ( cwd , 'dir' ) , { dot : true } ) ;
178179 const globbedAssets = await globAssets ( { cwd} , [ [ 'dir' ] ] ) ;
179180
180181 t . deepEqual ( sortAssets ( globbedAssets ) , sortAssets ( [ 'dir' , 'dir/upload_other.txt' , 'dir/upload.txt' , 'dir/.dotfile' ] ) ) ;
181182} ) ;
182183
183184test ( 'Include empty tempy.directory as defined' , async ( t ) => {
184185 const cwd = tempy . directory ( ) ;
185- await copy ( fixtures , cwd ) ;
186- await ensureDir ( resolve ( cwd , 'empty' ) ) ;
186+ await cpy ( fixtures , cwd , { dot : true } ) ;
187+ await mkdir ( resolve ( cwd , 'empty' ) , { recursive : true } ) ;
187188 const globbedAssets = await globAssets ( { cwd} , [ [ 'empty' ] ] ) ;
188189
189190 t . deepEqual ( globbedAssets , [ 'empty' ] ) ;
190191} ) ;
191192
192193test ( 'Deduplicate resulting files path' , async ( t ) => {
193194 const cwd = tempy . directory ( ) ;
194- await copy ( fixtures , cwd ) ;
195+ await cpy ( fixtures , cwd , { dot : true } ) ;
195196 const globbedAssets = await globAssets ( { cwd} , [ './upload.txt' , resolve ( cwd , 'upload.txt' ) , 'upload.txt' ] ) ;
196197
197198 t . is ( globbedAssets . length , 1 ) ;
0 commit comments