Files
docx-js/src/export/packer/local.ts
2018-03-21 10:53:07 +01:00

22 lines
568 B
TypeScript

import * as fs from "fs";
import { File } from "../../file";
import { Compiler } from "./compiler";
import { IPacker } from "./packer";
export class LocalPacker implements IPacker {
private stream: fs.WriteStream;
private readonly packer: Compiler;
constructor(file: File) {
this.packer = new Compiler(file);
}
public async pack(filePath: string): Promise<void> {
filePath = filePath.replace(/.docx$/, "");
this.stream = fs.createWriteStream(`${filePath}.docx`);
await this.packer.compile(this.stream);
}
}