Merge pull request #6 from felipeochoa/master

fix capitalization typo in tests. closes #2
This commit is contained in:
Dolan
2017-03-07 14:13:28 +00:00
committed by GitHub
9 changed files with 40 additions and 21 deletions

1
.gitignore vendored
View File

@ -34,6 +34,7 @@ node_modules
# build
build
build-tests
# vscode
ts/.vscode

View File

@ -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);

View File

@ -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"
}
}

View File

@ -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();
}
}

View File

@ -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");

View File

@ -1,7 +1,8 @@
{
"compilerOptions": {
"target": "es6",
"outDir": "../../build/tests",
"outDir": "../build-tests",
"rootDir": "./",
"module": "commonjs"
}
}
}

View File

@ -2,7 +2,7 @@
/// <reference path="../../typings/lodash/lodash.d.ts" />
/// <reference path="../../typings/chai/chai.d.ts" />
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";

View File

@ -3,6 +3,7 @@
/// <reference path="../../typings/archiver/archiver.d.ts" />
/// <reference path="../../typings/xml/xml.d.ts" />
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);
});
});
});

View File

@ -19169,4 +19169,4 @@ declare module "lodash" {
interface Set<T> {}
interface Map<K, V> {}
interface WeakSet<T> {}
interface WeakMap<K, V> {}
// interface WeakMap<K, V> {}