Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async parseBundleId (wdaBundlePath) {
const infoPlistPath = path.join(wdaBundlePath, 'Info.plist');
const infoPlist = await plist.parsePlist(await fs.readFile(infoPlistPath));
if (!infoPlist.CFBundleIdentifier) {
throw new Error(`Couldn't find bundle id in ${infoPlistPath}`);
}
return infoPlist.CFBundleIdentifier;
}
.trim()
.replace(/(\r\n|\n|\r)/gm, ' ')
.split(' ')
.map((str) => str.trim())
.filter((str) => str !== '');
arr = arr.slice(4);
const data = arr
.map((str) => parseInt(str, 16));
if (data.length === 0) {
console.log('no data');
return;
}
const buf = Buffer.from(data);
try {
const doc = plist.parsePlist(buf);
console.log(util.jsonStringify(doc));
} catch (err) {
if (err.message.includes('maxObjectCount exceeded')) {
return str;
}
console.log('ERROR:', err.message);
}
}
return '';
}
async readPairRecord (udid, timeout = 5000) {
const { tag, receivePromise } = this._receivePlistPromise(timeout);
this._sendPlist({
tag,
payload: {
MessageType: 'ReadPairRecord',
PairRecordID: udid,
ProgName: PROG_NAME,
ClientVersionString: CLIENT_VERSION_STRING
}
});
const data = await receivePromise;
if (data.payload.PairRecordData) {
try {
return plist.parsePlist(data.payload.PairRecordData);
} catch (err) {
throw new Error(`Unexpected data: ${JSON.stringify(data)}`);
}
} else {
return null;
}
}
_decode (data) {
const header = {
length: data.readUInt32LE(0),
version: data.readUInt32LE(4),
type: data.readUInt32LE(8),
tag: data.readUInt32LE(12)
};
let payload = data.slice(HEADER_LENGTH, data.length);
this.push({ header, payload: plist.parsePlist(payload) });
}
_decode (data) {
const payload = data.slice(HEADER_LENGTH, data.length);
if (_.isEmpty(payload)) {
return;
}
const object = plist.parsePlist(payload);
if (!object) {
return;
}
this.push(object);
}
}