From 0c128ae4a59186f18127b22ee2078a42359cdb28 Mon Sep 17 00:00:00 2001 From: felipe Date: Mon, 13 Mar 2017 20:35:27 +0100 Subject: [PATCH 1/2] add template to npm bundle --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 2cee1629ad..c8751c321d 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ }, "files": [ "ts", - "build" + "build", + "template" ], "repository": { "type": "git", From c7b7b585bef0f43475b505c459e84495df4127dd Mon Sep 17 00:00:00 2001 From: felipe Date: Mon, 13 Mar 2017 20:35:42 +0100 Subject: [PATCH 2/2] fix path to template when installed via npm I'm not sure why, buy app-root-path was not picking up the correct path for this module when installed via NPM. Since we're already using relative paths for imports, I don't think we gain much from using it anyway, so I've changed to using path.resolve instead --- package.json | 2 -- ts/export/packer/packer.ts | 8 +++++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index c8751c321d..1408a7fdde 100644 --- a/package.json +++ b/package.json @@ -29,10 +29,8 @@ "clippy" ], "dependencies": { - "@types/app-root-path": "^1.2.4", "@types/archiver": "^0.15.37", "@types/express": "^4.0.35", - "app-root-path": "^2.0.1", "archiver": "^1.3.0", "xml": "^1.0.1" }, diff --git a/ts/export/packer/packer.ts b/ts/export/packer/packer.ts index 3da1291911..167d178f8a 100644 --- a/ts/export/packer/packer.ts +++ b/ts/export/packer/packer.ts @@ -1,5 +1,5 @@ -import * as appRoot from "app-root-path"; import * as archiver from "archiver"; +import * as path from "path"; import * as xml from "xml"; import { Document } from "../../docx"; import { Numbering } from "../../numbering"; @@ -8,6 +8,8 @@ import { Styles } from "../../styles"; import { DefaultStylesFactory } from "../../styles/factory"; import { Formatter } from "../formatter"; +const templatePath = path.resolve(__dirname, "../../../template"); + export abstract class Packer { protected archive: any; protected document: Document; @@ -53,12 +55,12 @@ export abstract class Packer { this.archive.pipe(output); this.archive.glob("**", { expand: true, - cwd: appRoot.path + "/template", + cwd: templatePath, }); this.archive.glob("**/.rels", { expand: true, - cwd: appRoot.path + "/template", + cwd: templatePath, }); const xmlDocument = xml(this.formatter.format(this.document));