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
|
build
|
||||||
|
build-tests
|
||||||
|
|
||||||
# vscode
|
# vscode
|
||||||
ts/.vscode
|
ts/.vscode
|
||||||
|
@ -60,7 +60,7 @@ var docx = require('docx');
|
|||||||
```js
|
```js
|
||||||
var doc = new docx.Document();
|
var doc = new docx.Document();
|
||||||
|
|
||||||
var paragraph = new docx.Paragraph(),
|
var paragraph = new docx.Paragraph();
|
||||||
var text = new docx.TextRun('Hello World');
|
var text = new docx.TextRun('Hello World');
|
||||||
paragraph.addText(text);
|
paragraph.addText(text);
|
||||||
doc.addParagraph(paragraph);
|
doc.addParagraph(paragraph);
|
||||||
|
12
package.json
12
package.json
@ -4,8 +4,8 @@
|
|||||||
"description": "Generate .docx documents with JavaScript (formerly Office-Clippy)",
|
"description": "Generate .docx documents with JavaScript (formerly Office-Clippy)",
|
||||||
"main": "build/index.js",
|
"main": "build/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"pretest": "rimraf ./build/tests && tsc -p ts/tests",
|
"pretest": "rimraf ./build-tests && tsc -p ts/test-tsconfig.json",
|
||||||
"test": "mocha ./build/tests/**/*.*",
|
"test": "mocha ./build-tests --recursive",
|
||||||
"prepublish": "tsc -p ts"
|
"prepublish": "tsc -p ts"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@ -19,8 +19,8 @@
|
|||||||
"doc"
|
"doc"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"app-root-path": "^1.0.0",
|
"app-root-path": "^2.0.1",
|
||||||
"archiver": "^0.21.0",
|
"archiver": "^1.3.0",
|
||||||
"lodash": "^4.6.1",
|
"lodash": "^4.6.1",
|
||||||
"xml": "^1.0.1"
|
"xml": "^1.0.1"
|
||||||
},
|
},
|
||||||
@ -35,8 +35,8 @@
|
|||||||
"homepage": "https://github.com/dolanmiu/docx#readme",
|
"homepage": "https://github.com/dolanmiu/docx#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"chai": "^3.5.0",
|
"chai": "^3.5.0",
|
||||||
"mocha": "^2.4.5",
|
"mocha": "^3.2.0",
|
||||||
"rimraf": "^2.5.2",
|
"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 {
|
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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -51,13 +51,15 @@ export abstract class Packer {
|
|||||||
pack(output: any): void {
|
pack(output: any): void {
|
||||||
this.archive.pipe(output);
|
this.archive.pipe(output);
|
||||||
console.log(appRoot.path + "/template");
|
console.log(appRoot.path + "/template");
|
||||||
this.archive.bulk([
|
this.archive.glob("**", {
|
||||||
{
|
expand: true,
|
||||||
expand: true,
|
cwd: appRoot.path + "/template",
|
||||||
cwd: appRoot.path + "/template",
|
});
|
||||||
src: ["**", "**/.rels"]
|
|
||||||
}
|
this.archive.glob("**/.rels", {
|
||||||
]);
|
expand: true,
|
||||||
|
cwd: appRoot.path + "/template",
|
||||||
|
});
|
||||||
|
|
||||||
// this.archive.file(appRoot.path + "/template/[Content_Types].xml", { name: "[Content_Types].xml" });
|
// this.archive.file(appRoot.path + "/template/[Content_Types].xml", { name: "[Content_Types].xml" });
|
||||||
// console.log(__dirname + "/packer.js");
|
// console.log(__dirname + "/packer.js");
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es6",
|
"target": "es6",
|
||||||
"outDir": "../../build/tests",
|
"outDir": "../build-tests",
|
||||||
|
"rootDir": "./",
|
||||||
"module": "commonjs"
|
"module": "commonjs"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,7 +2,7 @@
|
|||||||
/// <reference path="../../typings/lodash/lodash.d.ts" />
|
/// <reference path="../../typings/lodash/lodash.d.ts" />
|
||||||
/// <reference path="../../typings/chai/chai.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 * as docx from "../../docx";
|
||||||
import {Attributes} from "../../docx/xml-components";
|
import {Attributes} from "../../docx/xml-components";
|
||||||
import {Properties} from "../../properties";
|
import {Properties} from "../../properties";
|
||||||
|
@ -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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
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 Set<T> {}
|
||||||
interface Map<K, V> {}
|
interface Map<K, V> {}
|
||||||
interface WeakSet<T> {}
|
interface WeakSet<T> {}
|
||||||
interface WeakMap<K, V> {}
|
// interface WeakMap<K, V> {}
|
||||||
|
Reference in New Issue
Block a user