feat(archive): add rar extraction support
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -228,3 +228,32 @@ describe('archive converters — 7z and tar.7z', () => {
|
||||
20000
|
||||
);
|
||||
});
|
||||
|
||||
describe('archive converters — rar (extraction only)', () => {
|
||||
it('lists rar as a source with the other 6 archive formats as targets, and never lists rar as a target for anything', () => {
|
||||
const targets = listTargetFormats('rar');
|
||||
expect(targets.sort()).toEqual(['7z', 'tar', 'tar.7z', 'tar.bz2', 'tar.gz', 'zip'].sort());
|
||||
expect(listTargetFormats('zip')).not.toContain('rar');
|
||||
});
|
||||
|
||||
it('converts the sample.rar fixture to zip', async () => {
|
||||
const rarPath = path.join(import.meta.dirname, '..', 'fixtures', 'sample.rar');
|
||||
const outputPath = path.join(tmpDir, 'from-rar.zip');
|
||||
const entry = resolve('rar', 'zip');
|
||||
|
||||
await entry.convert(rarPath, outputPath);
|
||||
|
||||
const outZip = new AdmZip(outputPath);
|
||||
expect(outZip.getEntries().length).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('archive converters — full registration matrix', () => {
|
||||
it('registers all 42 source/target pairs (7 sources x 6 targets)', () => {
|
||||
const sources = ['zip', 'tar', 'tar.gz', 'tar.bz2', '7z', 'tar.7z', 'rar'];
|
||||
const targets = ['zip', 'tar', 'tar.gz', 'tar.bz2', '7z', 'tar.7z'];
|
||||
for (const source of sources) {
|
||||
expect(listTargetFormats(source).sort()).toEqual(targets.sort());
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
# RAR fixture attribution
|
||||
|
||||
`sample.rar` is a byte-identical copy of `testFiles/FolderTest.rar` from the
|
||||
[YuJianrong/node-unrar.js](https://github.com/YuJianrong/node-unrar.js)
|
||||
repository (MIT-licensed), used there for that project's own extraction
|
||||
tests. Reused here because there is no way to create a `.rar` fixture from
|
||||
this codebase — the `unrar` library's license bars any tool (including this
|
||||
project's own converters) from writing the RAR format, so RAR support is
|
||||
extraction-only everywhere, including in test fixtures.
|
||||
Vendored
BIN
Binary file not shown.
Reference in New Issue
Block a user