MCPcopy Create free account
hub / github.com/ember-cli/ember-cli / isUsingBatteryUpower

Function isUsingBatteryUpower

lib/models/hardware-info.js:90–106  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

88}
89
90function isUsingBatteryUpower() {
91 try {
92 const { stdout } = execa.sync('upower', ['--enumerate']);
93 const devices = stdout.split('\n').filter(Boolean);
94
95 return devices.some((device) => {
96 const { stdout } = execa.sync('upower', ['--show-info', device]);
97
98 return /\bpower supply:\s+yes\b/.test(stdout) && /\bstate:\s+discharging\b/.test(stdout);
99 });
100 } catch (ex) {
101 logger.warn(`Could not get battery status from upower: ${ex}`);
102 logger.warn(ex.stack);
103
104 return null;
105 }
106}
107
108function isUsingBatteryWindows() {
109 try {

Callers 2

isUsingBatteryBsdFunction · 0.85
isUsingBatteryLinuxFunction · 0.85

Calls 1

filterMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…