Used my updated typings for archiver 1.3
This commit is contained in:
@ -33,7 +33,7 @@
|
|||||||
"clippy"
|
"clippy"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/archiver": "^0.15.37",
|
"@types/archiver": "^1.3.2",
|
||||||
"@types/express": "^4.0.35",
|
"@types/express": "^4.0.35",
|
||||||
"archiver": "^1.3.0",
|
"archiver": "^1.3.0",
|
||||||
"xml": "^1.0.1"
|
"xml": "^1.0.1"
|
||||||
|
@ -20,6 +20,6 @@ export class ExpressPacker extends Packer {
|
|||||||
|
|
||||||
public pack(name: string): void {
|
public pack(name: string): void {
|
||||||
this.res.attachment(`${name}.docx`);
|
this.res.attachment(`${name}.docx`);
|
||||||
super.pack(this.res);
|
super.compile(this.res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,6 @@ export class LocalPacker extends Packer {
|
|||||||
public pack(path: string): void {
|
public pack(path: string): void {
|
||||||
path = path.replace(/.docx$/, "");
|
path = path.replace(/.docx$/, "");
|
||||||
this.stream = fs.createWriteStream(`${path}.docx`);
|
this.stream = fs.createWriteStream(`${path}.docx`);
|
||||||
super.pack(this.stream);
|
super.compile(this.stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import * as archiver from "archiver";
|
import * as archiver from "archiver";
|
||||||
|
import * as express from "express";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import * as xml from "xml";
|
import * as xml from "xml";
|
||||||
@ -13,7 +14,7 @@ import { Formatter } from "../formatter";
|
|||||||
const TEMPLATE_PATH = path.resolve(__dirname, "../../../template");
|
const TEMPLATE_PATH = path.resolve(__dirname, "../../../template");
|
||||||
|
|
||||||
export abstract class Packer {
|
export abstract class Packer {
|
||||||
protected archive: any;
|
protected archive: archiver.Archiver;
|
||||||
private formatter: Formatter;
|
private formatter: Formatter;
|
||||||
private style: Styles;
|
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.pipe(output);
|
||||||
this.archive.glob("**", {
|
this.archive.glob("**", {
|
||||||
expand: true,
|
|
||||||
cwd: TEMPLATE_PATH,
|
cwd: TEMPLATE_PATH,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.archive.glob("**/.rels", {
|
this.archive.glob("**/.rels", {
|
||||||
expand: true,
|
|
||||||
cwd: TEMPLATE_PATH,
|
cwd: TEMPLATE_PATH,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user