diff --git a/.gitignore b/.gitignore
index f1b858463b..8ad7afb99c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -34,6 +34,7 @@ node_modules
# build
build
+build-tests
# vscode
ts/.vscode
diff --git a/README.md b/README.md
index acaad65c96..bdfb4e6388 100644
--- a/README.md
+++ b/README.md
@@ -60,7 +60,7 @@ var docx = require('docx');
```js
var doc = new docx.Document();
-var paragraph = new docx.Paragraph(),
+var paragraph = new docx.Paragraph();
var text = new docx.TextRun('Hello World');
paragraph.addText(text);
doc.addParagraph(paragraph);
diff --git a/package.json b/package.json
index a4a248aa0e..8774e774ef 100644
--- a/package.json
+++ b/package.json
@@ -4,8 +4,8 @@
"description": "Generate .docx documents with JavaScript (formerly Office-Clippy)",
"main": "build/index.js",
"scripts": {
- "pretest": "rimraf ./build/tests && tsc -p ts/tests",
- "test": "mocha ./build/tests/**/*.*",
+ "pretest": "rimraf ./build-tests && tsc -p ts/test-tsconfig.json",
+ "test": "mocha ./build-tests --recursive",
"prepublish": "tsc -p ts"
},
"repository": {
@@ -19,8 +19,8 @@
"doc"
],
"dependencies": {
- "app-root-path": "^1.0.0",
- "archiver": "^0.21.0",
+ "app-root-path": "^2.0.1",
+ "archiver": "^1.3.0",
"lodash": "^4.6.1",
"xml": "^1.0.1"
},
@@ -35,8 +35,8 @@
"homepage": "https://github.com/dolanmiu/docx#readme",
"devDependencies": {
"chai": "^3.5.0",
- "mocha": "^2.4.5",
+ "mocha": "^3.2.0",
"rimraf": "^2.5.2",
- "typescript": "^1.8.10"
+ "typescript": "^2.2.1"
}
}
diff --git a/ts/export/packer/local.ts b/ts/export/packer/local.ts
index afdf1c5255..63d13179da 100644
--- a/ts/export/packer/local.ts
+++ b/ts/export/packer/local.ts
@@ -14,6 +14,5 @@ export class LocalPacker extends Packer {
pack(path: string): void {
this.stream = fs.createWriteStream(path);
super.pack(this.stream);
- this.stream.close();
}
}
\ No newline at end of file
diff --git a/ts/export/packer/packer.ts b/ts/export/packer/packer.ts
index c2f39b7acd..8d19918ec9 100644
--- a/ts/export/packer/packer.ts
+++ b/ts/export/packer/packer.ts
@@ -51,13 +51,15 @@ export abstract class Packer {
pack(output: any): void {
this.archive.pipe(output);
console.log(appRoot.path + "/template");
- this.archive.bulk([
- {
- expand: true,
- cwd: appRoot.path + "/template",
- src: ["**", "**/.rels"]
- }
- ]);
+ this.archive.glob("**", {
+ expand: true,
+ cwd: appRoot.path + "/template",
+ });
+
+ this.archive.glob("**/.rels", {
+ expand: true,
+ cwd: appRoot.path + "/template",
+ });
// this.archive.file(appRoot.path + "/template/[Content_Types].xml", { name: "[Content_Types].xml" });
// console.log(__dirname + "/packer.js");
diff --git a/ts/tests/tsconfig.json b/ts/test-tsconfig.json
similarity index 58%
rename from ts/tests/tsconfig.json
rename to ts/test-tsconfig.json
index 61178dd153..844ea999ff 100644
--- a/ts/tests/tsconfig.json
+++ b/ts/test-tsconfig.json
@@ -1,7 +1,8 @@
{
"compilerOptions": {
"target": "es6",
- "outDir": "../../build/tests",
+ "outDir": "../build-tests",
+ "rootDir": "./",
"module": "commonjs"
}
-}
\ No newline at end of file
+}
diff --git a/ts/tests/export/formatterTest.ts b/ts/tests/export/formatterTest.ts
index 243a483e41..4a85bf68d5 100644
--- a/ts/tests/export/formatterTest.ts
+++ b/ts/tests/export/formatterTest.ts
@@ -2,7 +2,7 @@
///
///
-import {Formatter} from "../../export/Formatter";
+import {Formatter} from "../../export/formatter";
import * as docx from "../../docx";
import {Attributes} from "../../docx/xml-components";
import {Properties} from "../../properties";
diff --git a/ts/tests/export/localPackerTest.ts b/ts/tests/export/localPackerTest.ts
index bad36cba4c..af034e6653 100644
--- a/ts/tests/export/localPackerTest.ts
+++ b/ts/tests/export/localPackerTest.ts
@@ -3,6 +3,7 @@
///
///
+import * as fs from "fs";
import {LocalPacker} from "../../export/packer/local";
import {assert} from "chai";
import {Document} from "../../docx/document";
@@ -35,8 +36,23 @@ describe("Packer", () => {
describe("#pack()", () => {
it("should create a standard docx file", function (done) {
this.timeout(99999999);
- packer.pack("build/tests/test.docx");
- setTimeout(done, 1900);
+ packer.pack("build-tests/tests/test.docx");
+ 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);
});
});
});
\ No newline at end of file
diff --git a/ts/typings/lodash/lodash.d.ts b/ts/typings/lodash/lodash.d.ts
index 790107369d..6d0e85d774 100644
--- a/ts/typings/lodash/lodash.d.ts
+++ b/ts/typings/lodash/lodash.d.ts
@@ -19169,4 +19169,4 @@ declare module "lodash" {
interface Set {}
interface Map {}
interface WeakSet {}
-interface WeakMap {}
+// interface WeakMap {}