Used my updated typings for archiver 1.3

This commit is contained in:
Dolan
2017-05-09 18:03:31 +01:00
parent 8876bb1fea
commit 2ec171d4a8
4 changed files with 6 additions and 7 deletions

View File

@ -33,7 +33,7 @@
"clippy"
],
"dependencies": {
"@types/archiver": "^0.15.37",
"@types/archiver": "^1.3.2",
"@types/express": "^4.0.35",
"archiver": "^1.3.0",
"xml": "^1.0.1"

View File

@ -20,6 +20,6 @@ export class ExpressPacker extends Packer {
public pack(name: string): void {
this.res.attachment(`${name}.docx`);
super.pack(this.res);
super.compile(this.res);
}
}

View File

@ -16,6 +16,6 @@ export class LocalPacker extends Packer {
public pack(path: string): void {
path = path.replace(/.docx$/, "");
this.stream = fs.createWriteStream(`${path}.docx`);
super.pack(this.stream);
super.compile(this.stream);
}
}

View File

@ -1,4 +1,5 @@
import * as archiver from "archiver";
import * as express from "express";
import * as fs from "fs";
import * as path from "path";
import * as xml from "xml";
@ -13,7 +14,7 @@ import { Formatter } from "../formatter";
const TEMPLATE_PATH = path.resolve(__dirname, "../../../template");
export abstract class Packer {
protected archive: any;
protected archive: archiver.Archiver;
private formatter: Formatter;
private style: Styles;
@ -43,15 +44,13 @@ export abstract class Packer {
});
}
public pack(output: Express.Response | fs.WriteStream): void {
protected compile(output: fs.WriteStream | express.Response): void {
this.archive.pipe(output);
this.archive.glob("**", {
expand: true,
cwd: TEMPLATE_PATH,
});
this.archive.glob("**/.rels", {
expand: true,
cwd: TEMPLATE_PATH,
});