fixed injection of document into packer
This commit is contained in:
@ -1,12 +1,13 @@
|
|||||||
import {Packer} from "./packer";
|
import {Packer} from "./packer";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import * as express from "express";
|
import * as express from "express";
|
||||||
|
import {Document} from "../../docx/document";
|
||||||
|
|
||||||
export class ExpressPacker extends Packer {
|
export class ExpressPacker extends Packer {
|
||||||
private res: express.Response;
|
private res: express.Response;
|
||||||
|
|
||||||
constructor(res: express.Response) {
|
constructor(document: Document, res: express.Response) {
|
||||||
super();
|
super(document);
|
||||||
this.res = res;
|
this.res = res;
|
||||||
|
|
||||||
this.res.on('close', () => {
|
this.res.on('close', () => {
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
import {Packer} from "./packer";
|
import {Packer} from "./packer";
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
import {Document} from "../../docx/document";
|
||||||
|
|
||||||
export class LocalPacker extends Packer {
|
export class LocalPacker extends Packer {
|
||||||
private stream: fs.WriteStream
|
private stream: fs.WriteStream
|
||||||
|
|
||||||
constructor(path: string) {
|
constructor(document: Document, path: string) {
|
||||||
super();
|
super(document);
|
||||||
this.stream = fs.createWriteStream(path);
|
this.stream = fs.createWriteStream(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
import * as archiver from "archiver";
|
import * as archiver from "archiver";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import {Formatter} from "../formatter";
|
import {Formatter} from "../formatter";
|
||||||
|
import {Document} from "../../docx";
|
||||||
|
|
||||||
export abstract class Packer {
|
export abstract class Packer {
|
||||||
protected archive: any;
|
protected archive: any;
|
||||||
private formatter: Formatter;
|
private formatter: Formatter;
|
||||||
|
protected document: Document;
|
||||||
|
|
||||||
constructor() {
|
constructor(document: Document) {
|
||||||
this.formatter = new Formatter();
|
this.formatter = new Formatter();
|
||||||
|
this.document = document;
|
||||||
this.archive = archiver.create("zip", {});
|
this.archive = archiver.create("zip", {});
|
||||||
|
|
||||||
this.archive.on('error', (err) => {
|
this.archive.on('error', (err) => {
|
||||||
|
@ -8,7 +8,7 @@ function jsonify(obj: Object) {
|
|||||||
return JSON.parse(stringifiedJson);
|
return JSON.parse(stringifiedJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('Body', () => {
|
describe.only('Body', () => {
|
||||||
var body: Body;
|
var body: Body;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -16,6 +16,9 @@ describe('Body', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('#constructor()', () => {
|
describe('#constructor()', () => {
|
||||||
|
|
||||||
|
it("should create the correct xml components", () => {
|
||||||
|
console.log(body);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
@ -4,12 +4,14 @@
|
|||||||
|
|
||||||
import {LocalPacker} from "../export/packer/local";
|
import {LocalPacker} from "../export/packer/local";
|
||||||
import {assert} from "chai";
|
import {assert} from "chai";
|
||||||
|
import {Document} from "../docx/document"
|
||||||
|
|
||||||
describe.only('Packer', () => {
|
describe('Packer', () => {
|
||||||
var packer: LocalPacker;
|
var packer: LocalPacker;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
packer = new LocalPacker("test.zip");
|
var document = new Document();
|
||||||
|
packer = new LocalPacker(document, "build/tests/test.zip");
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#pack()', () => {
|
describe('#pack()', () => {
|
||||||
|
Reference in New Issue
Block a user