Skip to content

Instantly share code, notes, and snippets.

@thirdknife
Last active July 29, 2017 07:59
Show Gist options
  • Save thirdknife/775d5eed45c10cff81b4f2962b3f8109 to your computer and use it in GitHub Desktop.
Save thirdknife/775d5eed45c10cff81b4f2962b3f8109 to your computer and use it in GitHub Desktop.
var R = require('ramda')
var fs = require('fs')
var Promise = require("bluebird");
var logFile = fs.readFileSync('Project.xml', {encoding: 'utf8'})
var parseString = require('xml2js').parseString;
var readXMLFile = Promise.promisify(parseString);
var parseLog = R.composeP(
console.log,
R.prop('Project'),
readXMLFile
);
parseLog(logFile);
/*{ Project:
{ '$':
{ Version: '3',
MapDefines: 'Default',
PhysicsLookup: 'Default',
IDMapper: 'Default',
Mesh: '....',
PreviewResolution: '1.0',
FlipY: 'false',
HQCurvature: 'true',
SeamTermination: 'false' },
Materials: [ [Object] ] } }
returns
{ '$':
{ Version: '3',
MapDefines: 'Default',
PhysicsLookup: 'Default',
IDMapper: 'Default',
Mesh: '.....',
PreviewResolution: '1.0',
FlipY: 'false',
HQCurvature: 'true',
SeamTermination: 'false' },
Materials: [ { Camera1: [Object] } ] }
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment