File tree Expand file tree Collapse file tree 3 files changed +1364
-1272
lines changed
Expand file tree Collapse file tree 3 files changed +1364
-1272
lines changed Original file line number Diff line number Diff line change 1+ ### 3.0.1
2+
3+ - removed dynamic requires to allow for bundling #154
4+ - add ibm platform (os400) #158
5+
16### 3.0
27
38- removes node 8 support
Original file line number Diff line number Diff line change 33const fs = require ( 'fs' )
44const os = require ( 'os' )
55
6+ const requireMap = {
7+ ps : ( ) => require ( './ps' ) ,
8+ procfile : ( ) => require ( './procfile' ) ,
9+ wmic : ( ) => require ( './wmic' )
10+ }
11+
612const platformToMethod = {
713 aix : 'ps' ,
814 os400 : 'ps' ,
@@ -18,7 +24,6 @@ const platformToMethod = {
1824 win : 'wmic'
1925}
2026
21- const ps = require ( './ps' )
2227let platform = os . platform ( )
2328
2429if ( fs . existsSync ( '/etc/alpine-release' ) ) {
@@ -31,7 +36,7 @@ if (platform.match(/^win/)) {
3136
3237let stat
3338try {
34- stat = require ( './' + platformToMethod [ platform ] )
39+ stat = requireMap [ platformToMethod [ platform ] ] ( )
3540} catch ( err ) { }
3641
3742/**
@@ -50,10 +55,10 @@ try {
5055function get ( pids , options , callback ) {
5156 let fn = stat
5257 if ( platform !== 'win' && options . usePs === true ) {
53- fn = ps
58+ fn = requireMap . ps ( )
5459 }
5560
56- if ( stat === undefined ) {
61+ if ( fn === undefined ) {
5762 return callback ( new Error ( os . platform ( ) + ' is not supported yet, please open an issue (https://github.com/soyuka/pidusage)' ) )
5863 }
5964
You can’t perform that action at this time.
0 commit comments