Skip to content

Commit ebc8b8b

Browse files
committed
readd handling keys with "!" as first char
1 parent 80de1e0 commit ebc8b8b

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

lib/Stats.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ class Stats {
2424
return this.compilation.errors.length > 0;
2525
}
2626

27+
normalizeFieldKey(field) {
28+
if(field[0] === "!") {
29+
return field.substr(1);
30+
}
31+
return field;
32+
}
33+
2734
toJson(options, forToString) {
2835
if(typeof options === "boolean" || typeof options === "string") {
2936
options = Stats.presetToOptions(options);
@@ -85,11 +92,13 @@ class Stats {
8592
return 0;
8693
}
8794

88-
if(a[field] === null && b[field] === null) return 0;
89-
if(a[field] === null) return 1;
90-
if(b[field] === null) return -1;
91-
if(a[field] === b[field]) return 0;
92-
return a[field] < b[field] ? -1 : 1;
95+
const fieldKey = this.normalizeFieldKey(field);
96+
97+
if(a[fieldKey] === null && b[fieldKey] === null) return 0;
98+
if(a[fieldKey] === null) return 1;
99+
if(b[fieldKey] === null) return -1;
100+
if(a[fieldKey] === b[fieldKey]) return 0;
101+
return a[fieldKey] < b[fieldKey] ? -1 : 1;
93102
};
94103

95104
const formatError = (e) => {

0 commit comments

Comments
 (0)