From 25d33adbb16a427457d8465a9bcfcf71683f2239 Mon Sep 17 00:00:00 2001 From: Sebastien Colladon Date: Tue, 22 Mar 2022 21:55:43 +0100 Subject: [PATCH] fix: xml header displayed twice --- src/service/inFileHandler.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/service/inFileHandler.js b/src/service/inFileHandler.js index ec64f36a..aa598065 100644 --- a/src/service/inFileHandler.js +++ b/src/service/inFileHandler.js @@ -13,7 +13,7 @@ const { XMLBuilder, XMLParser } = require('fast-xml-parser') const FULLNAME = 'fullName' const FULLNAME_XML_TAG = new RegExp(`<${FULLNAME}>(.*)`) const XML_TAG = new RegExp(`^[${MINUS}${PLUS}]?\\s*<([^(/><.)]+)>\\s*$`) -const XML_HEADER = '\n' +const XML_HEADER_TAG_END = '?>' const XML_PARSER_OPTION = { ignoreAttributes: false, ignoreNameSpace: false, @@ -80,8 +80,11 @@ class InFileHandler extends StandardHandler { ) }) const xmlBuilder = new XMLBuilder(JSON_PARSER_OPTION) - const xmlContent = XML_HEADER + xmlBuilder.build(result.fileContent) - await outputFile(join(this.config.output, this.line), xmlContent) + const xmlContent = xmlBuilder.build(result.fileContent) + await outputFile( + join(this.config.output, this.line), + xmlContent.replace(XML_HEADER_TAG_END, `${XML_HEADER_TAG_END}\n`) + ) } async _handleInDiff() {