@wmfs/xml2csv
Advanced tools
Comparing version 1.26.0 to 1.27.0
@@ -0,1 +1,17 @@ | ||
# [1.27.0](https://github.com/wmfs/xml2csv/compare/v1.26.0...v1.27.0) (2022-11-02) | ||
### 🛠 Builds | ||
* **deps-dev:** update dependency chai to v4.3.5 ([fc255e9](https://github.com/wmfs/xml2csv/commit/fc255e9e6837bc4e6623ee4f73533ec0f2d53de3)) | ||
* **deps-dev:** update dependency chai to v4.3.6 ([212b4a7](https://github.com/wmfs/xml2csv/commit/212b4a7730c5bb7ff7ed93c56e32a3da8bb32e03)) | ||
* **deps-dev:** update dependency mocha to v10 ([8f9cee3](https://github.com/wmfs/xml2csv/commit/8f9cee3b1c32cbc75422d443dc4d2c3802de2bcd)) | ||
* **deps-dev:** update dependency mocha to v10.1.0 ([81ca200](https://github.com/wmfs/xml2csv/commit/81ca200036b2e41bf864c4671bc727e243c57e2e)) | ||
* **deps-dev:** update dependency mocha to v9.2.1 ([d1fa0f9](https://github.com/wmfs/xml2csv/commit/d1fa0f97823e1d19cfad861e3ef404cbf6d40db9)) | ||
* **deps-dev:** update dependency mocha to v9.2.2 ([b4cc406](https://github.com/wmfs/xml2csv/commit/b4cc406ecb7a98cb38f868c0c508214d15f3f545)) | ||
* **deps-dev:** update dependency semantic-release to v19.0.3 ([6a0c9c7](https://github.com/wmfs/xml2csv/commit/6a0c9c76c85d040fe57567538dc1c91e904ebd35)) | ||
* **deps-dev:** update dependency semantic-release to v19.0.5 ([890cda4](https://github.com/wmfs/xml2csv/commit/890cda4a6497c447f5a7a73e9e20499586d7ffb2)) | ||
* **deps-dev:** update dependency standard to v17 ([36e888f](https://github.com/wmfs/xml2csv/commit/36e888f434d8491e10dc5d6aa194eefb4ab3ebe8)) | ||
* **deps:** update dependency debug to v4.3.4 ([1cb318c](https://github.com/wmfs/xml2csv/commit/1cb318cdefd35b9a388fa44d1960fb0b5b5fe5fc)) | ||
# [1.26.0](https://github.com/wmfs/xml2csv/compare/v1.25.0...v1.26.0) (2022-01-25) | ||
@@ -2,0 +18,0 @@ |
@@ -20,2 +20,5 @@ 'use strict' | ||
} | ||
if (options.strict !== false) { | ||
options.strict = true | ||
} | ||
@@ -29,3 +32,3 @@ if (options.csvPath) { | ||
const saxStream = sax.createStream(true) | ||
const saxStream = sax.createStream(options.strict) | ||
@@ -64,3 +67,3 @@ saxStream.on('error', function (err) { | ||
if (accepting) { | ||
if (text.trim() !== '\n' && text.trim() !== '') { | ||
if (text.trim() !== '\n' && text.trim() !== '' && (pathPartsString || '').length > 0) { | ||
dottie.set(currentObj, pathPartsString, text) | ||
@@ -75,3 +78,3 @@ } | ||
function (text) { | ||
if (accepting) { | ||
if (accepting && (pathPartsString || '').length > 0) { | ||
dottie.set(currentObj, pathPartsString, text) | ||
@@ -78,0 +81,0 @@ } |
{ | ||
"name": "@wmfs/xml2csv", | ||
"version": "1.26.0", | ||
"version": "1.27.0", | ||
"description": "Convert XML file to CSV file", | ||
@@ -24,3 +24,3 @@ "author": "West Midlands Fire Service", | ||
"dependencies": { | ||
"debug": "4.3.3", | ||
"debug": "4.3.4", | ||
"dottie": "2.0.2", | ||
@@ -32,3 +32,3 @@ "fs-extra": "10.0.0", | ||
"devDependencies": { | ||
"chai": "4.3.4", | ||
"chai": "4.3.6", | ||
"chai-subset": "1.6.0", | ||
@@ -38,6 +38,6 @@ "codecov": "3.8.3", | ||
"cz-conventional-changelog": "3.3.0", | ||
"mocha": "9.2.0", | ||
"mocha": "10.1.0", | ||
"nyc": "15.1.0", | ||
"semantic-release": "19.0.2", | ||
"standard": "16.0.4", | ||
"semantic-release": "19.0.5", | ||
"standard": "17.0.0", | ||
"@semantic-release/changelog": "6.0.1", | ||
@@ -44,0 +44,0 @@ "@semantic-release/git": "10.0.1" |
@@ -137,2 +137,3 @@ # xml2csv | ||
| `headerMap` | `[array]` | See the [Header Map](#headerMap) section for more details. | ||
| `strict` | `[boolean]` | Should the sax parser run in strict mode ? Defaults to `true`. | ||
@@ -139,0 +140,0 @@ ### <a name="headerMap"></a>options.headerMap |
@@ -11,2 +11,3 @@ /* eslint-env mocha */ | ||
const weirdOutput = path.resolve(__dirname, 'output', 'weirdCases.csv') | ||
const wronglyPlacedOutput = path.resolve(__dirname, 'output', 'wronglyPlaced.csv') | ||
@@ -16,2 +17,3 @@ beforeEach(() => { | ||
fs.removeSync(weirdOutput) | ||
fs.removeSync(wronglyPlacedOutput) | ||
}) | ||
@@ -117,2 +119,22 @@ | ||
}) | ||
it('should convert the XML file to a CSV ignoring weird texts at wrong place', async function () { | ||
const expectedFile = path.resolve(__dirname, 'expected', 'wronglyPlaced.csv') | ||
const res = await xml2csv({ | ||
xmlPath: path.resolve(__dirname, 'fixtures', 'wronglyPlaced.xml'), | ||
csvPath: wronglyPlacedOutput, | ||
rootXMLElement: 'Case', | ||
headerMap: [ | ||
['First', 'first', 'string'], | ||
['Second', 'second', 'string'] | ||
] | ||
}) | ||
expect(res).to.deep.equal({ count: 1 }) | ||
const output = fs.readFileSync(wronglyPlacedOutput, { encoding: 'utf8' }).split('\n') | ||
const expected = fs.readFileSync(expectedFile, { encoding: 'utf8' }).split('\n') | ||
expect(output).to.eql(expected) | ||
}) | ||
}) | ||
@@ -119,0 +141,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57057
15
386
165
+ Addeddebug@4.3.4(transitive)
- Removeddebug@4.3.3(transitive)
Updateddebug@4.3.4