@@ -88,9 +88,9 @@ test('don\'t delete files, but return them - async', async t => {
8888 } ) ;
8989 exists ( t , [ '1.tmp' , '2.tmp' , '3.tmp' , '4.tmp' , '.dot.tmp' ] ) ;
9090 t . deepEqual ( deletedFiles , [
91- path . join ( t . context . tmp , '2 .tmp' ) ,
91+ path . join ( t . context . tmp , '4 .tmp' ) ,
9292 path . join ( t . context . tmp , '3.tmp' ) ,
93- path . join ( t . context . tmp , '4 .tmp' )
93+ path . join ( t . context . tmp , '2 .tmp' )
9494 ] ) ;
9595} ) ;
9696
@@ -101,8 +101,79 @@ test('don\'t delete files, but return them - sync', t => {
101101 } ) ;
102102 exists ( t , [ '1.tmp' , '2.tmp' , '3.tmp' , '4.tmp' , '.dot.tmp' ] ) ;
103103 t . deepEqual ( deletedFiles , [
104- path . join ( t . context . tmp , '2 .tmp' ) ,
104+ path . join ( t . context . tmp , '4 .tmp' ) ,
105105 path . join ( t . context . tmp , '3.tmp' ) ,
106- path . join ( t . context . tmp , '4 .tmp' )
106+ path . join ( t . context . tmp , '2 .tmp' )
107107 ] ) ;
108108} ) ;
109+
110+ // Currently this only testable locally on an osx machine.
111+ // https://github.com/sindresorhus/del/issues/68
112+ test . serial ( 'does not throw EINVAL - async' , async t => {
113+ await del ( '**/*' , {
114+ cwd : t . context . tmp ,
115+ dot : true
116+ } ) ;
117+
118+ const nestedFile = path . resolve ( t . context . tmp , 'a/b/c/nested.js' ) ;
119+ const totalAttempts = 200 ;
120+
121+ let count = 0 ;
122+ while ( count !== totalAttempts ) {
123+ makeDir . sync ( nestedFile ) ;
124+
125+ // eslint-disable-next-line no-await-in-loop
126+ const removed = await del ( '**/*' , {
127+ cwd : t . context . tmp ,
128+ dot : true
129+ } ) ;
130+
131+ const expected = [
132+ path . resolve ( t . context . tmp , 'a/b/c/nested.js' ) ,
133+ path . resolve ( t . context . tmp , 'a/b/c' ) ,
134+ path . resolve ( t . context . tmp , 'a/b' ) ,
135+ path . resolve ( t . context . tmp , 'a' )
136+ ] ;
137+
138+ t . deepEqual ( removed , expected ) ;
139+
140+ count += 1 ;
141+ }
142+
143+ notExists ( t , [ ...fixtures , 'a' ] ) ;
144+ t . is ( count , totalAttempts ) ;
145+ } ) ;
146+
147+ test . serial ( 'does not throw EINVAL - sync' , t => {
148+ del . sync ( '**/*' , {
149+ cwd : t . context . tmp ,
150+ dot : true
151+ } ) ;
152+
153+ const nestedFile = path . resolve ( t . context . tmp , 'a/b/c/nested.js' ) ;
154+ const totalAttempts = 200 ;
155+
156+ let count = 0 ;
157+ while ( count !== totalAttempts ) {
158+ makeDir . sync ( nestedFile ) ;
159+
160+ const removed = del . sync ( '**/*' , {
161+ cwd : t . context . tmp ,
162+ dot : true
163+ } ) ;
164+
165+ const expected = [
166+ path . resolve ( t . context . tmp , 'a/b/c/nested.js' ) ,
167+ path . resolve ( t . context . tmp , 'a/b/c' ) ,
168+ path . resolve ( t . context . tmp , 'a/b' ) ,
169+ path . resolve ( t . context . tmp , 'a' )
170+ ] ;
171+
172+ t . deepEqual ( removed , expected ) ;
173+
174+ count += 1 ;
175+ }
176+
177+ notExists ( t , [ ...fixtures , 'a' ] ) ;
178+ t . is ( count , totalAttempts ) ;
179+ } ) ;
0 commit comments