Files
docx-js/ts/export/packer/packer.ts

30 lines
641 B
TypeScript
Raw Normal View History

2016-03-31 18:07:22 +01:00
import * as archiver from "archiver";
2016-03-31 18:03:16 +01:00
import * as fs from 'fs';
2016-03-31 15:49:42 +01:00
2016-03-31 15:45:48 +01:00
export class Packer {
2016-03-31 18:07:22 +01:00
protected archive: any;
2016-03-31 18:03:16 +01:00
constructor() {
2016-03-31 18:07:22 +01:00
this.archive = archiver.create("zip", {});
2016-03-31 19:04:54 +01:00
this.archive.on('error', (err) => {
throw err;
});
2016-03-31 18:03:16 +01:00
}
pack(output: fs.WriteStream): void {
this.archive.pipe(output);
this.archive.bulk([
{
expand: true,
cwd: __dirname + '/template',
src: ['**', '**/.rels']
}
]);
2016-03-31 19:04:54 +01:00
//this.archive.directory(__dirname + "/template", "/");
this.archive.finalize();
2016-03-31 18:03:16 +01:00
}
2016-03-31 15:45:48 +01:00
}