Fix linting errors

This commit is contained in:
Dolan
2018-09-06 09:09:36 +01:00
parent 4994bca34c
commit 7688aa99f6
2 changed files with 22 additions and 23 deletions

View File

@ -1,27 +1,26 @@
import { Document, Packer, Paragraph, ImportDocx } from "../build";
import * as fs from "fs"; import * as fs from "fs";
import { Document, ImportDocx, Packer, Paragraph } from "../build";
let importDocx = new ImportDocx(); const importDocx = new ImportDocx();
const filePath = "./demo/dotx/template.dotx"; const filePath = "./demo/dotx/template.dotx";
fs.readFile(filePath, (err, data) => { fs.readFile(filePath, (err, data) => {
if (err) { if (err) {
console.error(`failed to read file ${filePath}.`); throw new Error(`Failed to read file ${filePath}.`);
} }
else {
importDocx.extract(data).then(templateDocument => {
let options = {};
options['templateDocument'] = templateDocument;
const doc = new Document(options);
const paragraph = new Paragraph("Hello World");
doc.addParagraph(paragraph);
const packer = new Packer(); importDocx.extract(data).then((templateDocument) => {
packer.toBuffer(doc).then((buffer) => { const options = {
fs.writeFileSync("MyDocument.docx", buffer); templateDocument,
console.log('done. open MyDocument.docx'); };
});
const doc = new Document(options);
const paragraph = new Paragraph("Hello World");
doc.addParagraph(paragraph);
const packer = new Packer();
packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
}); });
} });
}); });

View File

@ -6,9 +6,9 @@ import {
FooterReferenceType, FooterReferenceType,
HeaderReference, HeaderReference,
HeaderReferenceType, HeaderReferenceType,
SectionPropertiesOptions,
IHeaderOptions,
IFooterOptions, IFooterOptions,
IHeaderOptions,
SectionPropertiesOptions,
} from "./document/body/section-properties"; } from "./document/body/section-properties";
import { FooterWrapper } from "./footer-wrapper"; import { FooterWrapper } from "./footer-wrapper";
import { FootNotes } from "./footnotes"; import { FootNotes } from "./footnotes";
@ -22,8 +22,8 @@ import { ExternalStylesFactory } from "./styles/external-styles-factory";
import { DefaultStylesFactory } from "./styles/factory"; import { DefaultStylesFactory } from "./styles/factory";
import { Table } from "./table"; import { Table } from "./table";
type DocumentHeaders = { header: HeaderWrapper; type: HeaderReferenceType }[]; type DocumentHeaders = Array<{ header: HeaderWrapper; type: HeaderReferenceType }>;
type DocumentFooters = { footer: FooterWrapper; type: FooterReferenceType }[]; type DocumentFooters = Array<{ footer: FooterWrapper; type: FooterReferenceType }>;
export class File { export class File {
private readonly document: Document; private readonly document: Document;