don't close packer local packer stream prematurely closes #5

This commit is contained in:
felipe
2017-03-07 13:36:12 +01:00
parent cfdbaf2694
commit 9b9d748477
2 changed files with 18 additions and 3 deletions

View File

@ -14,6 +14,5 @@ export class LocalPacker extends Packer {
pack(path: string): void { pack(path: string): void {
this.stream = fs.createWriteStream(path); this.stream = fs.createWriteStream(path);
super.pack(this.stream); super.pack(this.stream);
this.stream.close();
} }
} }

View File

@ -3,6 +3,7 @@
/// <reference path="../../typings/archiver/archiver.d.ts" /> /// <reference path="../../typings/archiver/archiver.d.ts" />
/// <reference path="../../typings/xml/xml.d.ts" /> /// <reference path="../../typings/xml/xml.d.ts" />
import * as fs from "fs";
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"; import {Document} from "../../docx/document";
@ -35,8 +36,23 @@ describe("Packer", () => {
describe("#pack()", () => { describe("#pack()", () => {
it("should create a standard docx file", function (done) { it("should create a standard docx file", function (done) {
this.timeout(99999999); this.timeout(99999999);
packer.pack("build/tests/test.docx"); packer.pack("build-tests/tests/test.docx");
setTimeout(done, 1900); let int = setInterval(() => {
const stats = fs.statSync("build-tests/tests/test.docx");
if (stats.size > 2000) {
clearInterval(int);
clearTimeout(out);
done();
}
}, 1000);
let out = setTimeout(() => {
clearInterval(int);
try {
assert(false, 'did not create a file within the alloted time');
} catch (e){
done(e);
}
}, 2000);
}); });
}); });
}); });