File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ const createFile = (opt: TarOptionsFile, files: string[]) => {
3333 p . on ( 'error' , rej )
3434 } )
3535
36- addFilesAsync ( p , files )
36+ addFilesAsync ( p , files ) . catch ( er => p . emit ( 'error' , er ) )
3737
3838 return promise
3939}
@@ -79,7 +79,7 @@ const createSync = (opt: TarOptionsSync, files: string[]) => {
7979
8080const createAsync = ( opt : TarOptions , files : string [ ] ) => {
8181 const p = new Pack ( opt )
82- addFilesAsync ( p , files )
82+ addFilesAsync ( p , files ) . catch ( er => p . emit ( 'error' , er ) )
8383 return p
8484}
8585
Original file line number Diff line number Diff line change @@ -289,6 +289,37 @@ t.test('must specify some files', t => {
289289 t . end ( )
290290} )
291291
292+ t . test ( 'error from @ file entry should be catchable' , t => {
293+ t . test ( 'async with file option' , t => {
294+ const file = path . resolve ( dir , 'at-error-file.tar' )
295+ t . rejects (
296+ c (
297+ {
298+ file : file ,
299+ cwd : __dirname ,
300+ } ,
301+ [ '@nonexistent.tar' ] ,
302+ ) ,
303+ ) . then ( ( ) => t . end ( ) )
304+ } )
305+
306+ t . test ( 'async without file option' , t => {
307+ const stream = c (
308+ {
309+ cwd : __dirname ,
310+ } ,
311+ [ '@nonexistent.tar' ] ,
312+ )
313+ stream . on ( 'error' , er => {
314+ t . match ( er , { code : 'ENOENT' } )
315+ t . end ( )
316+ } )
317+ stream . resume ( )
318+ } )
319+
320+ t . end ( )
321+ } )
322+
292323t . test ( 'transform a filename' , async t => {
293324 const cwd = t . testdir ( {
294325 'README.md' : 'hello, world' ,
You can’t perform that action at this time.
0 commit comments