Merge pull request #6 from felipeochoa/master
fix capitalization typo in tests. closes #2
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -34,6 +34,7 @@ node_modules
|
||||
|
||||
# build
|
||||
build
|
||||
build-tests
|
||||
|
||||
# vscode
|
||||
ts/.vscode
|
||||
|
@ -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);
|
||||
|
12
package.json
12
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"
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
@ -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");
|
||||
|
@ -1,7 +1,8 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es6",
|
||||
"outDir": "../../build/tests",
|
||||
"outDir": "../build-tests",
|
||||
"rootDir": "./",
|
||||
"module": "commonjs"
|
||||
}
|
||||
}
|
||||
}
|
@ -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";
|
||||
|
@ -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);
|
||||
});
|
||||
});
|
||||
});
|
2
ts/typings/lodash/lodash.d.ts
vendored
2
ts/typings/lodash/lodash.d.ts
vendored
@ -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> {}
|
||||
|
Reference in New Issue
Block a user