From 0bb52bb9f9f49e0bfdd2865077a57c082156d3b5 Mon Sep 17 00:00:00 2001 From: felipe Date: Tue, 7 Mar 2017 12:46:42 +0100 Subject: [PATCH 1/8] fix capitalization typo in tests. closes #2 --- ts/tests/export/formatterTest.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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"; From 4e8136a5bd4c9b0e61c202177db17a82ad02f950 Mon Sep 17 00:00:00 2001 From: felipe Date: Tue, 7 Mar 2017 12:51:38 +0100 Subject: [PATCH 2/8] fix typo in README closes #4 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); From ca1715864eec23a05435841e2ff20bc6aab8a504 Mon Sep 17 00:00:00 2001 From: felipe Date: Tue, 7 Mar 2017 13:34:01 +0100 Subject: [PATCH 3/8] make sure all tests are running --- package.json | 4 ++-- ts/{tests/tsconfig.json => test-tsconfig.json} | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) rename ts/{tests/tsconfig.json => test-tsconfig.json} (58%) diff --git a/package.json b/package.json index a4a248aa0e..4752004953 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": { 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 +} From cfdbaf269448fc3e4658285c1f3ea1f90fde5ac2 Mon Sep 17 00:00:00 2001 From: felipe Date: Tue, 7 Mar 2017 13:35:39 +0100 Subject: [PATCH 4/8] add the new build-tests directory to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) 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 From 9b9d7484774647086282ca480a88832bd0414304 Mon Sep 17 00:00:00 2001 From: felipe Date: Tue, 7 Mar 2017 13:36:12 +0100 Subject: [PATCH 5/8] don't close packer local packer stream prematurely closes #5 --- ts/export/packer/local.ts | 1 - ts/tests/export/localPackerTest.ts | 20 ++++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) 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/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 From 46c870fafc3c0bbf54cebc3b51eaf73c04579d63 Mon Sep 17 00:00:00 2001 From: felipe Date: Tue, 7 Mar 2017 13:49:21 +0100 Subject: [PATCH 6/8] update dependencies and fix archive.bulk deprecation --- package.json | 4 ++-- ts/export/packer/packer.ts | 16 +++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 4752004953..6936f93d61 100644 --- a/package.json +++ b/package.json @@ -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" }, 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"); From 6c9af6f9e6c8e223926e26ca41c65c855bb8d75e Mon Sep 17 00:00:00 2001 From: felipe Date: Tue, 7 Mar 2017 13:51:11 +0100 Subject: [PATCH 7/8] update dev dependencies --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6936f93d61..8774e774ef 100644 --- a/package.json +++ b/package.json @@ -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" } } From 20014b06cb2eab1876abd29d7f51a97ada04ab90 Mon Sep 17 00:00:00 2001 From: felipe Date: Tue, 7 Mar 2017 13:52:54 +0100 Subject: [PATCH 8/8] fix TS WeakMap complaints See https://github.com/DefinitelyTyped/DefinitelyTyped/issues/14324 Closes #3 --- ts/typings/lodash/lodash.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 {}