Skip to content

Commit

Permalink
fix: correctly parse reports generated on win32 boxes; closes #62
Browse files Browse the repository at this point in the history
Windows-generated reports do not have the `userLimits` prop.
Adds test
  • Loading branch information
boneskull committed Nov 13, 2019
1 parent fb2771d commit eaed969
Show file tree
Hide file tree
Showing 5 changed files with 1,011 additions and 11 deletions.
28 changes: 17 additions & 11 deletions packages/common/src/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,23 @@ class Report {
* @param {any} value
*/
static isReportLike(value) {
return (
Report.isReport(value) ||
(_.isObject(value) &&
_.every(key => {
const hasValue = _.has(key, value);
if (!hasValue) {
debug(`report is missing prop "${key}"`);
}
return hasValue;
}, REPORT_KNOWN_ROOT_PROPERTIES))
);
if (Report.isReport(value)) {
return true;
}
if (_.isObject(value)) {
// win32 doesn't report 'userLimits'
const propsToCheck =
_.get('header.platform', value) === 'win32'
? _.pull('userLimits', REPORT_KNOWN_ROOT_PROPERTIES)
: REPORT_KNOWN_ROOT_PROPERTIES;
return _.every(key => {
const hasValue = _.has(key, value);
if (!hasValue) {
debug(`report is missing prop "${key}"`);
}
return hasValue;
}, propsToCheck);
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions packages/common/src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import pick from 'lodash/fp/pick.js';
import pickBy from 'lodash/fp/pickBy.js';
import pipe from 'lodash/fp/pipe.js';
import __ from 'lodash/fp/placeholder.js';
import pull from 'lodash/fp/pull.js';
import reduce from 'lodash/fp/reduce.js';
import reverse from 'lodash/fp/reverse.js';
import size from 'lodash/fp/size.js';
Expand Down Expand Up @@ -144,6 +145,7 @@ export const _ = {
pick,
pickBy,
pipe,
pull,
reduce,
reverse,
size,
Expand Down

0 comments on commit eaed969

Please sign in to comment.