Add XML parser

This commit is contained in:
C-3PO 2018-06-23 20:20:03 +02:00
parent 2d55189248
commit f01a880ae6
Signed by: c3po
GPG key ID: 62993C4BB4D86F24
4 changed files with 23 additions and 4 deletions

View file

@ -4,8 +4,8 @@ import getSolidpkg from './ssn/getSolidpkg';
(async () => {
//----- PATCHMANIFEST -----
//.patchmanifest files contain a single XML file called "manifest.xml"
//const patchmanifestXml = await getPatchmanifest('assets_swtor_de_de');
//console.log(patchmanifestXml);
const patchmanifestJson = await getPatchmanifest('assets_swtor_de_de');
console.log(patchmanifestJson);
//----- SOLIDPKG -----
//.solidpkg files contain a single Bencode file called "metafile.solid"

View file

@ -1,4 +1,5 @@
import { TextDecoder } from 'util';
import * as xmlJs from 'xml-js';
import getUrlContents from '../cdn/getUrlContents';
import { Product } from '../interfaces/ISettings';
import verifyProductName from '../ssn/verifyProductName';
@ -7,7 +8,7 @@ import readSsnFile from './readSsnFile';
const Decoder = new TextDecoder('utf-8');
export default async function getPatchmanifest(product: Product): Promise<string> {
export default async function getPatchmanifest(product: Product): Promise<any> {
//Verify function arguments
if (!verifyProductName(product)) {
throw new Error(`"${product}" is not a valid product.`);
@ -32,5 +33,7 @@ export default async function getPatchmanifest(product: Product): Promise<string
const patchmanifestFile = await extractFile(firstFile, [new DataView(ssnFile)]);
const patchmanifestXml = Decoder.decode(patchmanifestFile);
return patchmanifestXml;
const patchManifestJson = xmlJs.xml2js(patchmanifestXml);
return patchManifestJson;
}