Skip to content

Commit

Permalink
use xml2js to replace xml2json to prevent build process when npm inst…
Browse files Browse the repository at this point in the history
  • Loading branch information
huan committed Aug 7, 2018
1 parent 3df8664 commit 8a9a38d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"@types/request": "^2.47.1",
"@types/semver": "^5.5.0",
"@types/sinon": "^5.0.1",
"@types/xml2json": "^0.10.0",
"@types/xml2js": "^0.4.3",
"ajv": "^6.5.2",
"babel-eslint": "^8.2.5",
"blue-tape": "^1.0.0",
Expand Down Expand Up @@ -105,6 +105,6 @@
"rxjs": "^6.2.1",
"state-switch": "^0.6.2",
"watchdog": "^0.8.12",
"xml2json": "^0.11.2"
"xml2js": "^0.4.19"
}
}
19 changes: 13 additions & 6 deletions src/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
// tslint:disable:arrow-parens

import { EventEmitter } from 'events'
import fs from 'fs'
import path from 'path'

import fs from 'fs'
import path from 'path'
import {
Browser,
Cookie,
Expand All @@ -30,8 +29,8 @@ import {
Page,
} from 'puppeteer'
import StateSwitch from 'state-switch'
// import { parseString } from 'xml2js'
import { toJson } from 'xml2json'
import { parseString } from 'xml2js'
// import { toJson } from 'xml2json'

import {
MemoryCard,
Expand Down Expand Up @@ -799,7 +798,15 @@ export class Bridge extends EventEmitter {
try {
// see unit test for detail
const tryXmlText = this.preHtmlToXml(text)
obj = JSON.parse(toJson(tryXmlText))
// obj = JSON.parse(toJson(tryXmlText))
obj = await new Promise((resolve, reject) => {
parseString(tryXmlText, { explicitArray: false }, (err, result) => {
if (err) {
return reject(err)
}
return resolve(result)
})
})
} catch (e) {
log.warn('PuppetPuppeteerBridge', 'testBlockedMessage() toJson() exception: %s', e)
return false
Expand Down

0 comments on commit 8a9a38d

Please sign in to comment.