Skip to content

Commit da38e59

Browse files
Yanis Bensonsindresorhus
andauthored
Make interactive mode work under Windows (#69)
Co-authored-by: Sindre Sorhus <[email protected]>
1 parent f4c08ec commit da38e59

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

interactive.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,27 @@ const preferNotMatching = matches => (a, b) => {
2929
const deprioritizedProcesses = new Set(['iTerm', 'iTerm2', 'fkill']);
3030
const isDeprioritizedProcess = process_ => deprioritizedProcesses.has(process_.name);
3131
const preferNotDeprioritized = preferNotMatching(isDeprioritizedProcess);
32-
const preferHighPerformanceImpact = (a, b) => numSort.descending(a.cpu + a.memory, b.cpu + b.memory);
3332
const preferLowAlphanumericNames = (a, b) => a.name.localeCompare(b.name);
3433

34+
const preferHighPerformanceImpact = (a, b) => {
35+
const hasCpu = typeof a.cpu === 'number' && typeof b.cpu === 'number';
36+
const hasMemory = typeof a.memory === 'number' && typeof b.memory === 'number';
37+
38+
if (hasCpu && hasMemory) {
39+
return numSort.descending(a.cpu + a.memory, b.cpu + b.memory);
40+
}
41+
42+
if (hasCpu) {
43+
return numSort.descending(a.cpu, b.cpu);
44+
}
45+
46+
if (hasMemory) {
47+
return numSort.descending(a.memory, b.memory);
48+
}
49+
50+
return 0;
51+
};
52+
3553
const preferHeurisicallyInterestingProcesses = (a, b) => {
3654
let result;
3755

0 commit comments

Comments
 (0)