Archiver update from 0.15.0 to 1.3.x (#15894)

* archiver clean up and updated version

* added tslint.json

* added back in create because it still works. Updated examples

* fixed listing issues

* fixed more linting issues

* added glob options and EntryData

* added more to tests

* fixed tests by returning this, instead of void

* removed whitespace

* Add node types import

* Keep original author
This commit is contained in:
Dolan
2017-05-02 01:08:44 +01:00
committed by Mohamed Hegazy
parent 18e3ce9627
commit 1ee58c5114
2 changed files with 49 additions and 23 deletions

View File

@@ -1,26 +1,36 @@
import Archiver = require('archiver');
import FS = require('fs');
import * as Archiver from 'archiver';
import * as fs from 'fs';
const archiver = Archiver.create('zip');
const writeStream = FS.createWriteStream('./archiver.d.ts');
const readStream = FS.createReadStream('./archiver.d.ts');
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: 'archiver.d.ts'})
.append(readStream, {name: 'archiver.d.ts'});
archiver.bulk({ mappaing: {} });
archiver.directory('./path', './someOtherPath');
archiver.directory('./path', { name: "testName"} );
archiver.directory('./path', { name: "testName" });
archiver.directory('./', "", {});
archiver.directory('./', {name: 'test'}, {});
archiver.directory('./', { name: 'test' }, {});
archiver.append(readStream, {
name: "sub/folder.xml"
});
archiver.glob("**", {
cwd: 'path/to/files',
});
archiver.glob('./path', {}, {});
archiver.file('./path', { name: 'test' });
archiver.glob('./path', {}, {});
archiver.finalize();
archiver.setFormat('zip');
archiver.setModule(() => {});
@@ -28,4 +38,4 @@ archiver.setModule(() => {});
archiver.pointer();
archiver.use(() => {});
archiver.pipe(writeStream);
archiver.finalize();

View File

@@ -1,51 +1,67 @@
// Type definitions for archiver 1.3
// Project: https://github.com/archiverjs/node-archiver
// Definitions by: Esri <https://github.com/archiverjs/node-archiver>
// Definitions by: Esri <https://github.com/archiverjs/node-archiver>, Dolan Miu <https://github.com/dolanmiu>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* =================== USAGE ===================
import Archiver = require('archiver);
var archiver = Archiver.create('zip');
archiver.pipe(FS.createWriteStream('xxx'));
archiver.append(FS.createReadStream('xxx'));
archiver.pipe(fs.createWriteStream('xxx'));
archiver.append(fs.createReadStream('xxx'));
archiver.finalize();
=============================================== */
/// <reference types="node" />
import * as FS from 'fs';
import * as STREAM from 'stream';
import * as fs from 'fs';
import * as stream from 'stream';
import * as express from 'express';
import * as glob from 'glob';
declare function archiver(format: string, options?: {}): archiver.Archiver;
declare function archiver(format: archiver.Format, options?: archiver.ArchiverOptions): archiver.Archiver;
declare namespace archiver {
function create(format: string, options?: {}): Archiver;
type Format = 'zip' | 'tar';
function create(format: string, options?: ArchiverOptions): Archiver;
function registerFormat(format: string, module: Function): void;
interface nameInterface {
interface EntryData {
name?: string;
prefix?: string;
stats?: string;
}
interface Archiver extends STREAM.Transform {
interface Archiver extends stream.Transform {
abort(): this;
append(source: STREAM.Readable | Buffer | string, name: nameInterface): this;
append(source: stream.Readable | Buffer | string, name?: EntryData): this;
bulk(mappings: any): this;
directory(dirpath: string, destpath: nameInterface | string, data?: any | Function): this;
directory(dirpath: string, options: EntryData | string, data?: EntryData): this;
file(filepath: string, data: any): this;
glob(pattern: string, options: {}, data: any): this;
file(filename: string, data: EntryData): this;
glob(pattern: string, options?: glob.IOptions, data?: EntryData): this;
finalize(): this;
pipe(stream: fs.WriteStream | express.Response): void;
setFormat(format: string): this;
setModule(module: Function): this;
pointer(): number;
use(plugin: Function): this;
}
interface ArchiverOptions {
store?: boolean;
gzip?: boolean;
gzipOptions?: {
level: number,
};
}
}
export = archiver;