Skip to content

Instantly share code, notes, and snippets.

@elinesterov
Created January 18, 2018 22:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elinesterov/c3981c0368aa646501eadf3610384fa5 to your computer and use it in GitHub Desktop.
Save elinesterov/c3981c0368aa646501eadf3610384fa5 to your computer and use it in GitHub Desktop.
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