Skip to content

Instantly share code, notes, and snippets.

@elinesterov elinesterov/index.js
Created Jan 18, 2018

Embed
What would you like to do?
test pm dump parsing
#!/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
You can’t perform that action at this time.