Skip to content

Commit d3fb048

Browse files
committed
Remove dynamic require call
Fix #16
1 parent 597e3f8 commit d3fb048

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/get.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,24 @@ var platformToMethod = {
1212
aix: 'ps',
1313
};
1414

15+
var methodToRequireFn = {
16+
ps: () => require('./ps'),
17+
wmic: () => require('./wmic'),
18+
};
19+
1520
var platform = os.platform();
1621
if (platform.startsWith('win')) {
1722
platform = 'win';
1823
}
1924

20-
var file = platformToMethod[platform];
25+
var method = platformToMethod[platform];
2126

2227
/**
2328
* Gets the list of all the pids of the system.
2429
* @param {Function} callback Called when the list is ready.
2530
*/
2631
function get(callback) {
27-
if (file === undefined) {
32+
if (method === undefined) {
2833
callback(
2934
new Error(
3035
os.platform() +
@@ -33,7 +38,7 @@ function get(callback) {
3338
);
3439
}
3540

36-
var list = require('./' + file);
41+
var list = methodToRequireFn[method]();
3742
list(callback);
3843
}
3944

0 commit comments

Comments
 (0)