Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const createFile = (opt: TarOptionsFile, files: string[]) => {
p.on('error', rej)
})

addFilesAsync(p, files)
addFilesAsync(p, files).catch(er => p.emit('error', er))

return promise
}
Expand Down Expand Up @@ -79,7 +79,7 @@ const createSync = (opt: TarOptionsSync, files: string[]) => {

const createAsync = (opt: TarOptions, files: string[]) => {
const p = new Pack(opt)
addFilesAsync(p, files)
addFilesAsync(p, files).catch(er => p.emit('error', er))
return p
}

Expand Down
31 changes: 31 additions & 0 deletions test/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,37 @@ t.test('must specify some files', t => {
t.end()
})

t.test('error from @ file entry should be catchable', t => {
t.test('async with file option', t => {
const file = path.resolve(dir, 'at-error-file.tar')
t.rejects(
c(
{
file: file,
cwd: __dirname,
},
['@nonexistent.tar'],
),
).then(() => t.end())
})

t.test('async without file option', t => {
const stream = c(
{
cwd: __dirname,
},
['@nonexistent.tar'],
)
stream.on('error', er => {
t.match(er, { code: 'ENOENT' })
t.end()
})
stream.resume()
})

t.end()
})

t.test('transform a filename', async t => {
const cwd = t.testdir({
'README.md': 'hello, world',
Expand Down
Loading