Skip to content
Open
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
3 changes: 2 additions & 1 deletion src/options.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// turn tar(1) style args like `C` into the more verbose things like `cwd`

import type { Minipass } from 'minipass'
import { type GzipOptions, type ZlibOptions } from 'minizlib'
import { type Stats } from 'node:fs'
import { type ReadEntry } from './read-entry.js'
Expand Down Expand Up @@ -248,7 +249,7 @@ export interface TarOptions {
*/
transform?: (
entry: ReadEntry,
) => ReadEntry | null | undefined | false | 0 | ''
) => ReadEntry | Minipass | null | undefined | false | 0 | ''

/**
* Call `chmod()` to ensure that extracted files match the entry's mode
Expand Down
16 changes: 16 additions & 0 deletions test/transform-type-check.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Minipass } from 'minipass'
import { extract } from '../src/extract.js'
import { Unpack } from '../src/unpack.js'

// MiniPass stream return (issue #462)
const streamTransform = () => new Minipass({ async: true })
extract({ transform: streamTransform }, [])
new Unpack({ transform: streamTransform })

// entry / falsey return remains valid (issue #459)
extract({ transform: entry => entry }, [])
extract({ transform: () => undefined }, [])
extract({ transform: () => false }, [])

import { pass } from 'tap'
pass(`transform may return a stream or a falsey value`)