ember-cli 4.0.0 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +4 -4
- package/CHANGELOG.md +42 -2
- package/blueprints/addon/additional-dev-dependencies.json +1 -1
- package/blueprints/addon/files/.github/workflows/ci.yml +0 -1
- package/blueprints/addon/files/.travis.yml +0 -1
- package/blueprints/addon/files/addon-config/ember-try.js +0 -13
- package/blueprints/app/files/config/environment.js +1 -1
- package/blueprints/app/files/package.json +6 -6
- package/docs/build/data.json +3 -3
- package/lib/models/host-info-cache.js +3 -5
- package/lib/models/per-bundle-addon-cache/index.js +2 -3
- package/lib/tasks/npm-task.js +1 -1
- package/lib/utilities/get-lang-arg.js +45 -45
- package/package.json +25 -25
- package/tests/helpers/mock-project.js +1 -1
- package/.github/ISSUE_TEMPLATE.md +0 -12
- package/.github/dependabot.yml +0 -15
- package/.github/workflows/coverage.yml +0 -31
- package/docs/analytics.md +0 -44
- package/docs/architecture.md +0 -316
- package/docs/assets/architecture/Ember-CLI architecture.png +0 -0
- package/docs/assets/architecture/Ember-CLI architecture.xml +0 -1
- package/docs/assets/architecture/README.md +0 -5
- package/docs/brocfile-transition.md +0 -46
- package/docs/build/api.js +0 -44
- package/docs/build/assets/css/external-small.png +0 -0
- package/docs/build/assets/css/logo.png +0 -0
- package/docs/build/assets/css/main.css +0 -555
- package/docs/build/assets/favicon.ico +0 -0
- package/docs/build/assets/img/spinner.gif +0 -0
- package/docs/build/assets/index.html +0 -10
- package/docs/build/assets/js/api-filter.js +0 -56
- package/docs/build/assets/js/api-list.js +0 -255
- package/docs/build/assets/js/api-search.js +0 -98
- package/docs/build/assets/js/apidocs.js +0 -376
- package/docs/build/assets/js/yui-prettify.js +0 -17
- package/docs/build/assets/vendor/prettify/CHANGES.html +0 -130
- package/docs/build/assets/vendor/prettify/COPYING +0 -202
- package/docs/build/assets/vendor/prettify/README.html +0 -203
- package/docs/build/assets/vendor/prettify/prettify-min.css +0 -1
- package/docs/build/assets/vendor/prettify/prettify-min.js +0 -1
- package/docs/build/classes/Addon.html +0 -4318
- package/docs/build/classes/AmdTransformAddon.html +0 -202
- package/docs/build/classes/Blueprint.html +0 -4796
- package/docs/build/classes/Builder.html +0 -611
- package/docs/build/classes/CLI.html +0 -810
- package/docs/build/classes/Command.html +0 -1655
- package/docs/build/classes/DefaultPackager.html +0 -202
- package/docs/build/classes/EmberAddon.html +0 -2207
- package/docs/build/classes/EmberApp.html +0 -2225
- package/docs/build/classes/HardwareInfo.html +0 -620
- package/docs/build/classes/HistorySupportAddon.html +0 -203
- package/docs/build/classes/Instrumentation.html +0 -695
- package/docs/build/classes/NodeModulesList.html +0 -460
- package/docs/build/classes/NpmTask.html +0 -333
- package/docs/build/classes/PackageInfo.html +0 -1390
- package/docs/build/classes/PackageInfoCache.html +0 -963
- package/docs/build/classes/PerBundleAddonCache {.html +0 -1010
- package/docs/build/classes/Project.html +0 -2083
- package/docs/build/classes/ServeFilesAddon.html +0 -260
- package/docs/build/classes/TestsServerAddon.html +0 -203
- package/docs/build/classes/WatcherAddon.html +0 -204
- package/docs/build/classes/WindowsSymlinkChecker.html +0 -1505
- package/docs/build/files/lib_broccoli_default-packager.js.html +0 -1426
- package/docs/build/files/lib_broccoli_ember-addon.js.html +0 -159
- package/docs/build/files/lib_broccoli_ember-app.js.html +0 -1913
- package/docs/build/files/lib_cli_cli.js.html +0 -417
- package/docs/build/files/lib_models_addon-info.js.html +0 -112
- package/docs/build/files/lib_models_addon.js.html +0 -1866
- package/docs/build/files/lib_models_blueprint.js.html +0 -1678
- package/docs/build/files/lib_models_builder.js.html +0 -417
- package/docs/build/files/lib_models_command.js.html +0 -804
- package/docs/build/files/lib_models_hardware-info.js.html +0 -479
- package/docs/build/files/lib_models_host-info-cache.js.html +0 -428
- package/docs/build/files/lib_models_installation-checker.js.html +0 -181
- package/docs/build/files/lib_models_instantiate-addons.js.html +0 -191
- package/docs/build/files/lib_models_instrumentation.js.html +0 -433
- package/docs/build/files/lib_models_package-info-cache_index.js.html +0 -793
- package/docs/build/files/lib_models_package-info-cache_node-modules-list.js.html +0 -208
- package/docs/build/files/lib_models_package-info-cache_package-info.js.html +0 -661
- package/docs/build/files/lib_models_per-bundle-addon-cache_addon-proxy.js.html +0 -252
- package/docs/build/files/lib_models_per-bundle-addon-cache_index.js.html +0 -485
- package/docs/build/files/lib_models_per-bundle-addon-cache_target-instance.js.html +0 -108
- package/docs/build/files/lib_models_project.js.html +0 -913
- package/docs/build/files/lib_models_task.js.html +0 -117
- package/docs/build/files/lib_tasks_build-watch.js.html +0 -157
- package/docs/build/files/lib_tasks_npm-task.js.html +0 -463
- package/docs/build/files/lib_tasks_serve.js.html +0 -207
- package/docs/build/files/lib_tasks_server_middleware_broccoli-serve-files_index.js.html +0 -127
- package/docs/build/files/lib_tasks_server_middleware_broccoli-watcher_index.js.html +0 -158
- package/docs/build/files/lib_tasks_server_middleware_history-support_index.js.html +0 -181
- package/docs/build/files/lib_tasks_server_middleware_tests-server_index.js.html +0 -171
- package/docs/build/files/lib_tasks_test-server.js.html +0 -167
- package/docs/build/files/lib_tasks_transforms_amd_index.js.html +0 -143
- package/docs/build/files/lib_utilities_ember-app-utils.js.html +0 -292
- package/docs/build/files/lib_utilities_insert-into-file.js.html +0 -219
- package/docs/build/files/lib_utilities_is-lazy-engine.js.html +0 -125
- package/docs/build/files/lib_utilities_is-yarn-project.js.html +0 -120
- package/docs/build/files/lib_utilities_valid-project-name.js.html +0 -142
- package/docs/build/files/lib_utilities_will-interrupt-process.js.html +0 -290
- package/docs/build/files/lib_utilities_windows-admin.js.html +0 -230
- package/docs/build/index.html +0 -125
- package/docs/build/modules/ember-cli.html +0 -152
- package/docs/build/modules/is-lazy-engine.html +0 -106
- package/docs/build-concurrency.md +0 -15
- package/docs/build-pipeline-debugging.md +0 -33
- package/docs/code-coverage.md +0 -14
- package/docs/error-propagation.md +0 -136
- package/docs/experiments.md +0 -53
- package/docs/node-support.md +0 -43
- package/docs/perf-guide.md +0 -250
- package/docs/project_version_preprocessor.js +0 -8
- package/docs/sourcemaps.md +0 -60
- package/docs/yuidoc.json +0 -13
|
@@ -1,479 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8">
|
|
5
|
-
<title>lib/models/hardware-info.js - ember-cli</title>
|
|
6
|
-
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
|
|
7
|
-
<link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
|
|
8
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/yui/3.18.0/yui/yui-min.js"></script>
|
|
9
|
-
</head>
|
|
10
|
-
<body class="yui3-skin-sam">
|
|
11
|
-
|
|
12
|
-
<div id="doc">
|
|
13
|
-
<div class="yui3-g">
|
|
14
|
-
<div id="sidebar" class="yui3-u">
|
|
15
|
-
<div class="logo">
|
|
16
|
-
<a href="../index.html">
|
|
17
|
-
<img src="https://ember-cli.com/assets/images/ember-cli-logo-small-dark.png">
|
|
18
|
-
</a>
|
|
19
|
-
</div>
|
|
20
|
-
|
|
21
|
-
<div id="modules" class="sidebox">
|
|
22
|
-
<div class="hd">
|
|
23
|
-
<h2 class="no-toc">Modules</h2>
|
|
24
|
-
</div>
|
|
25
|
-
<div class="bd">
|
|
26
|
-
<ul>
|
|
27
|
-
<li><a href="../modules/ember-cli.html">ember-cli</a>
|
|
28
|
-
</li>
|
|
29
|
-
<li><a href="../modules/is-lazy-engine.html">is-lazy-engine</a>
|
|
30
|
-
</li>
|
|
31
|
-
</ul>
|
|
32
|
-
</div>
|
|
33
|
-
</div>
|
|
34
|
-
|
|
35
|
-
<div id="classes" class="sidebox">
|
|
36
|
-
<div class="hd">
|
|
37
|
-
<h2 class="no-toc">Classes</h2>
|
|
38
|
-
</div>
|
|
39
|
-
<div class="bd">
|
|
40
|
-
<ul>
|
|
41
|
-
<li><a href="../classes/Addon.html">Addon</a></li>
|
|
42
|
-
<li><a href="../classes/AmdTransformAddon.html">AmdTransformAddon</a></li>
|
|
43
|
-
<li><a href="../classes/Blueprint.html">Blueprint</a></li>
|
|
44
|
-
<li><a href="../classes/Builder.html">Builder</a></li>
|
|
45
|
-
<li><a href="../classes/CLI.html">CLI</a></li>
|
|
46
|
-
<li><a href="../classes/Command.html">Command</a></li>
|
|
47
|
-
<li><a href="../classes/DefaultPackager.html">DefaultPackager</a></li>
|
|
48
|
-
<li><a href="../classes/EmberAddon.html">EmberAddon</a></li>
|
|
49
|
-
<li><a href="../classes/EmberApp.html">EmberApp</a></li>
|
|
50
|
-
<li><a href="../classes/HardwareInfo.html">HardwareInfo</a></li>
|
|
51
|
-
<li><a href="../classes/HistorySupportAddon.html">HistorySupportAddon</a></li>
|
|
52
|
-
<li><a href="../classes/Instrumentation.html">Instrumentation</a></li>
|
|
53
|
-
<li><a href="../classes/NodeModulesList.html">NodeModulesList</a></li>
|
|
54
|
-
<li><a href="../classes/NpmTask.html">NpmTask</a></li>
|
|
55
|
-
<li><a href="../classes/PackageInfo.html">PackageInfo</a></li>
|
|
56
|
-
<li><a href="../classes/PackageInfoCache.html">PackageInfoCache</a></li>
|
|
57
|
-
<li><a href="../classes/PerBundleAddonCache {.html">PerBundleAddonCache {</a></li>
|
|
58
|
-
<li><a href="../classes/Project.html">Project</a></li>
|
|
59
|
-
<li><a href="../classes/ServeFilesAddon.html">ServeFilesAddon</a></li>
|
|
60
|
-
<li><a href="../classes/TestsServerAddon.html">TestsServerAddon</a></li>
|
|
61
|
-
<li><a href="../classes/WatcherAddon.html">WatcherAddon</a></li>
|
|
62
|
-
<li><a href="../classes/WindowsSymlinkChecker.html">WindowsSymlinkChecker</a></li>
|
|
63
|
-
</ul>
|
|
64
|
-
</div>
|
|
65
|
-
</div>
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
<div class="version-info">
|
|
72
|
-
Version: 4.0.0-release-b4cbb1029f
|
|
73
|
-
</div>
|
|
74
|
-
|
|
75
|
-
</div>
|
|
76
|
-
|
|
77
|
-
<div id="main" class="yui3-u">
|
|
78
|
-
<div class="content"><div class="title">
|
|
79
|
-
<h1 class="file-name">lib/models/hardware-info.js</h1>
|
|
80
|
-
</div>
|
|
81
|
-
|
|
82
|
-
<pre class="code prettyprint linenums">
|
|
83
|
-
'use strict';
|
|
84
|
-
|
|
85
|
-
const execa = require('execa');
|
|
86
|
-
const fs = require('fs');
|
|
87
|
-
const logger = require('heimdalljs-logger')('ember-cli:hardware-info');
|
|
88
|
-
const os = require('os');
|
|
89
|
-
|
|
90
|
-
function isUsingBatteryAcpi() {
|
|
91
|
-
try {
|
|
92
|
-
const { stdout } = execa.sync('acpi', ['--ac-adapter']);
|
|
93
|
-
const lines = stdout.split('\n').filter(Boolean);
|
|
94
|
-
|
|
95
|
-
return lines.every((line) => /off-line/.test(line));
|
|
96
|
-
} catch (ex) {
|
|
97
|
-
logger.warn(`Could not get battery status from acpi: ${ex}`);
|
|
98
|
-
logger.warn(ex.stack);
|
|
99
|
-
|
|
100
|
-
return null;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function isUsingBatteryApm() {
|
|
105
|
-
try {
|
|
106
|
-
const { stdout } = execa.sync('apm', ['-a']);
|
|
107
|
-
|
|
108
|
-
return parseInt(stdout, 10) === 0;
|
|
109
|
-
} catch (ex) {
|
|
110
|
-
logger.warn(`Could not get battery status from apm: ${ex}`);
|
|
111
|
-
logger.warn(ex.stack);
|
|
112
|
-
|
|
113
|
-
return null;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function isUsingBatteryBsd() {
|
|
118
|
-
const apm = isUsingBatteryApm();
|
|
119
|
-
|
|
120
|
-
if (apm !== null) {
|
|
121
|
-
return apm;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return isUsingBatteryUpower();
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function isUsingBatteryDarwin() {
|
|
128
|
-
try {
|
|
129
|
-
const { stdout } = execa.sync('pmset', ['-g', 'batt']);
|
|
130
|
-
|
|
131
|
-
return stdout.indexOf('Battery Power') !== -1;
|
|
132
|
-
} catch (ex) {
|
|
133
|
-
logger.warn(`Could not get battery status from pmset: ${ex}`);
|
|
134
|
-
logger.warn(ex.stack);
|
|
135
|
-
|
|
136
|
-
return null;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
function isUsingBatteryLinux() {
|
|
141
|
-
const sysClassPowerSupply = isUsingBatterySysClassPowerSupply();
|
|
142
|
-
|
|
143
|
-
if (sysClassPowerSupply !== null) {
|
|
144
|
-
return sysClassPowerSupply;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
const acpi = isUsingBatteryAcpi();
|
|
148
|
-
|
|
149
|
-
if (acpi !== null) {
|
|
150
|
-
return acpi;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return isUsingBatteryUpower();
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function isUsingBatterySysClassPowerSupply() {
|
|
157
|
-
try {
|
|
158
|
-
const value = fs.readFileSync('/sys/class/power_supply/AC/online');
|
|
159
|
-
|
|
160
|
-
return parseInt(value, 10) === 0;
|
|
161
|
-
} catch (ex) {
|
|
162
|
-
logger.warn(`Could not get battery status from /sys/class/power_supply: ${ex}`);
|
|
163
|
-
logger.warn(ex.stack);
|
|
164
|
-
|
|
165
|
-
return null;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
function isUsingBatteryUpower() {
|
|
170
|
-
try {
|
|
171
|
-
const { stdout } = execa.sync('upower', ['--enumerate']);
|
|
172
|
-
const devices = stdout.split('\n').filter(Boolean);
|
|
173
|
-
|
|
174
|
-
return devices.some((device) => {
|
|
175
|
-
const { stdout } = execa.sync('upower', ['--show-info', device]);
|
|
176
|
-
|
|
177
|
-
return /\bpower supply:\s+yes\b/.test(stdout) && /\bstate:\s+discharging\b/.test(stdout);
|
|
178
|
-
});
|
|
179
|
-
} catch (ex) {
|
|
180
|
-
logger.warn(`Could not get battery status from upower: ${ex}`);
|
|
181
|
-
logger.warn(ex.stack);
|
|
182
|
-
|
|
183
|
-
return null;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
function isUsingBatteryWindows() {
|
|
188
|
-
try {
|
|
189
|
-
const { stdout } = execa.sync('wmic', [
|
|
190
|
-
'/namespace:',
|
|
191
|
-
'\\\\root\\WMI',
|
|
192
|
-
'path',
|
|
193
|
-
'BatteryStatus',
|
|
194
|
-
'get',
|
|
195
|
-
'PowerOnline',
|
|
196
|
-
'/format:list',
|
|
197
|
-
]);
|
|
198
|
-
|
|
199
|
-
return /\bPowerOnline=FALSE\b/.test(stdout);
|
|
200
|
-
} catch (ex) {
|
|
201
|
-
logger.warn(`Could not get battery status from wmic: ${ex}`);
|
|
202
|
-
logger.warn(ex.stack);
|
|
203
|
-
|
|
204
|
-
return null;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
function memorySwapUsedDarwin() {
|
|
209
|
-
try {
|
|
210
|
-
const { stdout } = execa.sync('sysctl', ['vm.swapusage']);
|
|
211
|
-
const match = /\bused = (\d+\.\d+)M\b/.exec(stdout);
|
|
212
|
-
|
|
213
|
-
if (!match) {
|
|
214
|
-
throw new Error('vm.swapusage not in output.');
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// convert from fractional megabytes to bytes
|
|
218
|
-
return parseFloat(match[1]) * 1048576;
|
|
219
|
-
} catch (ex) {
|
|
220
|
-
logger.warn(`Could not get swap status from sysctl: ${ex}`);
|
|
221
|
-
logger.warn(ex.stack);
|
|
222
|
-
|
|
223
|
-
return null;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
function memorySwapUsedBsd() {
|
|
228
|
-
try {
|
|
229
|
-
const { stdout } = execa.sync('pstat', ['-s']);
|
|
230
|
-
const devices = stdout.split('\n').filter(Boolean);
|
|
231
|
-
const header = devices.shift();
|
|
232
|
-
const match = /^Device\s+(\d+)(K?)-blocks\s+Used\b/.exec(header);
|
|
233
|
-
|
|
234
|
-
if (!match) {
|
|
235
|
-
throw new Error('Block size not found in output.');
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
const blockSize = parseInt(match[1], 10) * (match[2] === 'K' ? 1024 : 1);
|
|
239
|
-
|
|
240
|
-
return devices.reduce((total, line) => {
|
|
241
|
-
const match = /^\S+\s+\d+\s+(\d+)/.exec(line);
|
|
242
|
-
|
|
243
|
-
if (!match) {
|
|
244
|
-
throw new Error(`Unrecognized line in output: '${line}'`);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
return total + parseInt(match[1], 10) * blockSize;
|
|
248
|
-
}, 0);
|
|
249
|
-
} catch (ex) {
|
|
250
|
-
logger.warn(`Could not get swap status from pstat: ${ex}`);
|
|
251
|
-
logger.warn(ex.stack);
|
|
252
|
-
|
|
253
|
-
return null;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
function memorySwapUsedLinux() {
|
|
258
|
-
try {
|
|
259
|
-
const { stdout } = execa.sync('free', ['-b']);
|
|
260
|
-
const lines = stdout.split('\n').filter(Boolean);
|
|
261
|
-
const header = lines.shift();
|
|
262
|
-
const columns = header.split(/\s+/).filter(Boolean);
|
|
263
|
-
const columnUsed = columns.reduce((columnUsed, column, index) => {
|
|
264
|
-
if (columnUsed !== undefined) {
|
|
265
|
-
return columnUsed;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
if (/used/i.test(column)) {
|
|
269
|
-
// there is no heading on the first column, so indices are off by 1
|
|
270
|
-
return index + 1;
|
|
271
|
-
}
|
|
272
|
-
}, undefined);
|
|
273
|
-
|
|
274
|
-
if (columnUsed === undefined) {
|
|
275
|
-
throw new Error('Could not find "used" column.');
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
for (const line of lines) {
|
|
279
|
-
const columns = line.split(/\s+/).filter(Boolean);
|
|
280
|
-
|
|
281
|
-
if (/swap/i.test(columns[0])) {
|
|
282
|
-
return parseInt(columns[columnUsed], 10);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
throw new Error('Could not find "swap" row.');
|
|
287
|
-
} catch (ex) {
|
|
288
|
-
logger.warn(`Could not get swap status from free: ${ex}`);
|
|
289
|
-
logger.warn(ex.stack);
|
|
290
|
-
|
|
291
|
-
return null;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
function memorySwapUsedWindows() {
|
|
296
|
-
try {
|
|
297
|
-
const { stdout } = execa.sync('wmic', ['PAGEFILE', 'get', 'CurrentUsage', '/format:list']);
|
|
298
|
-
const match = /\bCurrentUsage=(\d+)/.exec(stdout);
|
|
299
|
-
|
|
300
|
-
if (!match) {
|
|
301
|
-
throw new Error('Page file usage info not in output.');
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
return parseInt(match[1], 10) * 1048576;
|
|
305
|
-
} catch (ex) {
|
|
306
|
-
logger.warn(`Could not get swap status from wmic: ${ex}`);
|
|
307
|
-
logger.warn(ex.stack);
|
|
308
|
-
|
|
309
|
-
return null;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
const hwinfo = {
|
|
314
|
-
/**
|
|
315
|
-
* Indicates whether the host is running on battery power. This can cause
|
|
316
|
-
* performance degredation.
|
|
317
|
-
*
|
|
318
|
-
* @private
|
|
319
|
-
* @method isUsingBattery
|
|
320
|
-
* @for HardwareInfo
|
|
321
|
-
* @param {String=process.platform} platform The current hardware platform.
|
|
322
|
-
* USED FOR TESTING ONLY.
|
|
323
|
-
* @return {null|Boolean} `true` iff the host is running on battery power or
|
|
324
|
-
* `false` if not. `null` if the battery status
|
|
325
|
-
* cannot be determined.
|
|
326
|
-
*/
|
|
327
|
-
isUsingBattery(platform = process.platform) {
|
|
328
|
-
switch (platform) {
|
|
329
|
-
case 'darwin':
|
|
330
|
-
return isUsingBatteryDarwin();
|
|
331
|
-
|
|
332
|
-
case 'freebsd':
|
|
333
|
-
case 'openbsd':
|
|
334
|
-
return isUsingBatteryBsd();
|
|
335
|
-
|
|
336
|
-
case 'linux':
|
|
337
|
-
return isUsingBatteryLinux();
|
|
338
|
-
|
|
339
|
-
case 'win32':
|
|
340
|
-
return isUsingBatteryWindows();
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
logger.warn(`Battery status is unsupported on the '${platform}' platform.`);
|
|
344
|
-
|
|
345
|
-
return null;
|
|
346
|
-
},
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* Determines the amount of swap/virtual memory currently in use.
|
|
350
|
-
*
|
|
351
|
-
* @private
|
|
352
|
-
* @method memorySwapUsed
|
|
353
|
-
* @param {String=process.platform} platform The current hardware platform.
|
|
354
|
-
* USED FOR TESTING ONLY.
|
|
355
|
-
* @return {null|Number} The amount of used swap space, in bytes. `null` if
|
|
356
|
-
* the used swap space cannot be determined.
|
|
357
|
-
*/
|
|
358
|
-
memorySwapUsed(platform = process.platform) {
|
|
359
|
-
switch (platform) {
|
|
360
|
-
case 'darwin':
|
|
361
|
-
return memorySwapUsedDarwin();
|
|
362
|
-
|
|
363
|
-
case 'freebsd':
|
|
364
|
-
case 'openbsd':
|
|
365
|
-
return memorySwapUsedBsd();
|
|
366
|
-
|
|
367
|
-
case 'linux':
|
|
368
|
-
return memorySwapUsedLinux();
|
|
369
|
-
|
|
370
|
-
case 'win32':
|
|
371
|
-
return memorySwapUsedWindows();
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
logger.warn(`Swap status is unsupported on the '${platform}' platform.`);
|
|
375
|
-
|
|
376
|
-
return null;
|
|
377
|
-
},
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* Determines the total amount of memory available to the host, as from
|
|
381
|
-
* `os.totalmem`.
|
|
382
|
-
*
|
|
383
|
-
* @private
|
|
384
|
-
* @method memoryTotal
|
|
385
|
-
* @return {Number} The total memory in bytes.
|
|
386
|
-
*/
|
|
387
|
-
memoryTotal() {
|
|
388
|
-
return os.totalmem();
|
|
389
|
-
},
|
|
390
|
-
|
|
391
|
-
/**
|
|
392
|
-
* Determines the amount of memory currently being used by the current Node
|
|
393
|
-
* process, as from `process.memoryUsage`.
|
|
394
|
-
*
|
|
395
|
-
* @private
|
|
396
|
-
* @method memoryUsed
|
|
397
|
-
* @return {Object} The Resident Set Size, as reported by
|
|
398
|
-
* `process.memoryUsage`.
|
|
399
|
-
*/
|
|
400
|
-
memoryUsed() {
|
|
401
|
-
return process.memoryUsage().rss;
|
|
402
|
-
},
|
|
403
|
-
|
|
404
|
-
/**
|
|
405
|
-
* Determines the number of logical processors available to the host, as from
|
|
406
|
-
* `os.cpus`.
|
|
407
|
-
*
|
|
408
|
-
* @private
|
|
409
|
-
* @method processorCount
|
|
410
|
-
* @return {Number} The number of logical processors.
|
|
411
|
-
*/
|
|
412
|
-
processorCount() {
|
|
413
|
-
return os.cpus().length;
|
|
414
|
-
},
|
|
415
|
-
|
|
416
|
-
/**
|
|
417
|
-
* Determines the average processor load across the system. This is
|
|
418
|
-
* expressed as a fractional number between 0 and the number of logical
|
|
419
|
-
* processors.
|
|
420
|
-
*
|
|
421
|
-
* @private
|
|
422
|
-
* @method processorLoad
|
|
423
|
-
* @param {String=process.platform} platform The current hardware platform.
|
|
424
|
-
* USED FOR TESTING ONLY.
|
|
425
|
-
* @return {Array<Number>} The one-, five-, and fifteen-minute processor load
|
|
426
|
-
* averages.
|
|
427
|
-
*/
|
|
428
|
-
processorLoad(platform = process.platform) {
|
|
429
|
-
// The os.loadavg() call works on win32, but never returns correct
|
|
430
|
-
// data. Better to intercept and warn that it's unsupported.
|
|
431
|
-
if (platform === 'win32') {
|
|
432
|
-
logger.warn(`Processor load is unsupported on the '${platform}' platform.`);
|
|
433
|
-
|
|
434
|
-
return null;
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
return os.loadavg();
|
|
438
|
-
},
|
|
439
|
-
|
|
440
|
-
/**
|
|
441
|
-
* Gets the speed of the host's processors.
|
|
442
|
-
*
|
|
443
|
-
* If more than one processor is found, the average of their speeds is taken.
|
|
444
|
-
*
|
|
445
|
-
* @private
|
|
446
|
-
* @method processorSpeed
|
|
447
|
-
* @return {Number} The average processor speed in MHz.
|
|
448
|
-
*/
|
|
449
|
-
processorSpeed() {
|
|
450
|
-
const cpus = os.cpus();
|
|
451
|
-
|
|
452
|
-
return cpus.reduce((sum, cpu) => sum + cpu.speed, 0) / cpus.length;
|
|
453
|
-
},
|
|
454
|
-
|
|
455
|
-
/**
|
|
456
|
-
* Determines the time since the host was started, as from `os.uptime`.
|
|
457
|
-
*
|
|
458
|
-
* @private
|
|
459
|
-
* @method uptime
|
|
460
|
-
* @return {Number} The number of seconds since the host was started.
|
|
461
|
-
*/
|
|
462
|
-
uptime() {
|
|
463
|
-
return os.uptime();
|
|
464
|
-
},
|
|
465
|
-
};
|
|
466
|
-
|
|
467
|
-
module.exports = hwinfo;
|
|
468
|
-
|
|
469
|
-
</pre>
|
|
470
|
-
|
|
471
|
-
</div>
|
|
472
|
-
</div>
|
|
473
|
-
</div>
|
|
474
|
-
</div>
|
|
475
|
-
<script src="../assets/vendor/prettify/prettify-min.js"></script>
|
|
476
|
-
<script>prettyPrint();</script>
|
|
477
|
-
<script src="../assets/js/yui-prettify.js"></script>
|
|
478
|
-
</body>
|
|
479
|
-
</html>
|