2016-05-26 15:08:34 +01:00
|
|
|
import * as fs from "fs";
|
2017-09-30 18:15:33 +01:00
|
|
|
|
2017-12-20 01:03:20 +00:00
|
|
|
import { File } from "../../file";
|
2017-12-06 01:03:14 +00:00
|
|
|
import { Compiler } from "./compiler";
|
|
|
|
import { IPacker } from "./packer";
|
2017-03-08 21:54:52 +00:00
|
|
|
|
2017-12-06 01:03:14 +00:00
|
|
|
export class LocalPacker implements IPacker {
|
2016-05-26 15:08:34 +01:00
|
|
|
private stream: fs.WriteStream;
|
2018-01-29 01:55:25 +00:00
|
|
|
private readonly packer: Compiler;
|
2016-05-26 15:08:34 +01:00
|
|
|
|
2017-12-15 02:15:44 +00:00
|
|
|
constructor(file: File) {
|
|
|
|
this.packer = new Compiler(file);
|
2016-03-31 18:03:16 +01:00
|
|
|
}
|
2016-05-26 15:08:34 +01:00
|
|
|
|
2017-12-06 01:32:57 +00:00
|
|
|
public async pack(filePath: string): Promise<void> {
|
2017-12-05 00:16:21 +00:00
|
|
|
filePath = filePath.replace(/.docx$/, "");
|
|
|
|
|
|
|
|
this.stream = fs.createWriteStream(`${filePath}.docx`);
|
2017-12-06 01:32:57 +00:00
|
|
|
await this.packer.compile(this.stream);
|
2016-05-26 15:08:34 +01:00
|
|
|
}
|
2017-03-08 21:54:52 +00:00
|
|
|
}
|