mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
- correct EntryData `name` property (always required) - add Zip*/Tar* entry data subtypes - provide a way to use EntryData `name` as optional - as required by the Archiver.directory(...) definition and usage in package - update version - minor code clenaup via Prettier Fixes: 42572 /cc @iherman Thanks!
81 lines
2.1 KiB
TypeScript
81 lines
2.1 KiB
TypeScript
import Archiver = require('archiver');
|
|
import * as fs from 'fs';
|
|
|
|
const options: Archiver.ArchiverOptions = {
|
|
statConcurrency: 1,
|
|
allowHalfOpen: true,
|
|
readableObjectMode: true,
|
|
writeableObjectMode: true,
|
|
decodeStrings: true,
|
|
encoding: 'test',
|
|
highWaterMark: 1,
|
|
objectmode: true,
|
|
comment: 'test',
|
|
forceLocalTime: true,
|
|
forceZip64: true,
|
|
store: true,
|
|
zlib: {},
|
|
gzip: true,
|
|
gzipOptions: {},
|
|
};
|
|
|
|
Archiver('zip', options);
|
|
|
|
const archiver = Archiver.create('zip');
|
|
|
|
const writeStream = fs.createWriteStream('./archiver.d.ts');
|
|
const readStream = fs.createReadStream('./archiver.d.ts');
|
|
|
|
archiver.abort();
|
|
|
|
archiver.pipe(writeStream);
|
|
archiver.append(readStream, { name: 'archiver.d.ts' });
|
|
archiver.append(readStream, { name: 'buffer.txt', date: '05/05/1991' });
|
|
archiver.append(readStream, { name: 'buffer.txt', date: new Date() });
|
|
archiver.append(readStream, { name: 'buffer.txt', mode: 1 });
|
|
archiver.append(readStream, { name: 'buffer.txt', mode: 1, stats: new fs.Stats() });
|
|
archiver.append('Some content', { name: 'filename', store: true });
|
|
archiver.append(readStream, { name: 'archiver.d.ts' }).append(readStream, { name: 'archiver.d.ts' });
|
|
|
|
archiver.directory('./path', './someOtherPath');
|
|
archiver.directory('./', '', {});
|
|
archiver.directory('./', false, { name: 'test' });
|
|
archiver.directory('./', false, (entry: Archiver.EntryData) => {
|
|
entry.name = 'foobar';
|
|
return entry;
|
|
});
|
|
archiver.directory('./', false, (entry: Archiver.EntryData) => false);
|
|
|
|
archiver.append(readStream, {
|
|
name: 'sub/folder.xml',
|
|
});
|
|
|
|
archiver.glob('**', {
|
|
cwd: 'path/to/files',
|
|
});
|
|
archiver.glob('./path', {}, {});
|
|
|
|
archiver.file('./path', { name: 'test' });
|
|
|
|
archiver.setFormat('zip');
|
|
archiver.setModule(() => {});
|
|
|
|
archiver.pointer();
|
|
archiver.use(() => {});
|
|
|
|
archiver.finalize();
|
|
|
|
archiver.symlink('./path', './target');
|
|
|
|
function fakeHandler(err: Archiver.ArchiverError) {
|
|
console.log(err.code);
|
|
console.log(err.message);
|
|
console.log(err.stack);
|
|
console.log(err.data);
|
|
}
|
|
|
|
const fakeError = new Archiver.ArchiverError('code', 'foo');
|
|
|
|
archiver.on('error', fakeHandler);
|
|
archiver.on('warning', fakeHandler);
|