From 4b4ec85bc4f49e72244f7219539124b45b876d8e Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Wed, 12 Aug 2015 21:57:45 +0100 Subject: Open zip file before passing to readers --- lib/docx/style-map.js | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) (limited to 'lib/docx/style-map.js') diff --git a/lib/docx/style-map.js b/lib/docx/style-map.js index dcc9f66..5020a87 100644 --- a/lib/docx/style-map.js +++ b/lib/docx/style-map.js @@ -1,5 +1,4 @@ var promises = require("../promises"); -var unzip = require("../unzip"); exports.writeStyleMap = writeStyleMap; exports.readStyleMap = readStyleMap; @@ -7,25 +6,14 @@ exports.readStyleMap = readStyleMap; var styleMapPath = "mammoth/style-map"; -function writeStyleMap(options) { - return promises.when(unzip.openZip(options)) - .then(function(zipFile) { - - zipFile.write(styleMapPath, options.styleMap); - - return { - toBuffer: zipFile.toBuffer - }; - }); +function writeStyleMap(docxFile, styleMap) { + docxFile.write(styleMapPath, styleMap); } -function readStyleMap(options) { - return promises.when(unzip.openZip(options)) - .then(function(zipFile) { - if (zipFile.exists(styleMapPath)) { - return zipFile.read(styleMapPath, "utf8"); - } else { - return promises.when(null); - } - }); +function readStyleMap(docxFile) { + if (docxFile.exists(styleMapPath)) { + return docxFile.read(styleMapPath, "utf8"); + } else { + return promises.resolve(null); + } } -- cgit v1.2.3