Last active
November 8, 2019 17:57
-
-
Save b-coimbra/1d1631e550874abbae13880d0a179a69 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const { execSync } = require('child_process'); | |
var parser = null; | |
const filename = process.argv[2]; | |
const outputFile = filename.split('.')[0] + '.txt'; | |
const filters = [ | |
"MD5" | |
]; | |
const install_pkg = async () => { | |
try { | |
parser = require('xml2json'); | |
} catch (error) { | |
execSync("npm install xml2json", (err, stdout, stderr) => console.log(stdout)); | |
parser = require('xml2json'); | |
} | |
}; | |
const output = (line) => | |
fs.appendFileSync(`./${outputFile}`, line + "\n", (err) => err && console.warn(err)); | |
install_pkg().then(() => { | |
fs.readFile(filename, (err, data) => { | |
const json = JSON.parse(parser.toJson(data)).steps.step; | |
for (let step of json) { | |
if (filters.length) | |
filters.forEach(f => delete step[f]); | |
output(Object.values(step).join(' ')); | |
} | |
}); | |
console.log("DONE"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment