Created
January 18, 2018 22:34
-
-
Save elinesterov/c3981c0368aa646501eadf3610384fa5 to your computer and use it in GitHub Desktop.
test pm dump parsing
This file contains 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
#!/usr/bin/env node | |
'use strict'; | |
function getReqPermissions (cmdOutput = null) { | |
let stdout = cmdOutput; | |
// not working regex | |
// let match = new RegExp(/requested permissions:([\s\S]*?)install permissions:/g).exec(stdout); | |
// working regex | |
let match = new RegExp(/requested permissions:([\s\S]*?)(install permissions:|User 0)/g).exec(stdout); | |
if (!match) { | |
throw new Error('Unable to get requested permissions'); | |
} | |
return match[0].match(/android\.permission\.\w+/g) || []; | |
}; | |
console.log('Start test'); | |
let fs = require('fs'); | |
var content = fs.readFileSync('working', 'utf8'); | |
// var content = fs.readFileSync('non_working', 'utf8'); | |
let res = getReqPermissions(content); | |
console.log('Parsed permissions: \n' + res); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment