New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to collect memory information from processes #11
Conversation
@@ -23,7 +23,7 @@ function buildProcessTree(processList, rootPid) { | |||
}; | |||
} | |||
|
|||
function getProcessTree(rootPid, callback) { | |||
function getProcessTree(rootPid, callback, flags) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need a corresponding change in the typings file
src/addon.cc
Outdated
return; | ||
} | ||
|
||
// Flags is an optional parameter. By default, all options for included process data are off. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make it a mandatory parameter in the C++ side and use flags || 0
on JS side to simplify things.
c2baa22
to
ef89a88
Compare
test.js
Outdated
native.getProcessList((list) => { | ||
assert.equal(list.some((p => p.memory !== 0)), true); | ||
done(); | ||
}, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use the flags enum here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so, since this is a js file. I can make a separate change to move to using typescript
test.js
Outdated
|
||
// Memory should be a number when flag is set | ||
native.getProcessList((list) => { | ||
assert.equal(list.some((p => p.memory !== 0)), true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> 0
to be safer since !== 0
will be true when it's undefined
.
typings/windows-process-tree.d.ts
Outdated
children: ProcessTreeNode[] | ||
} | ||
|
||
function get(rootPid: number, callback: (tree: ProcessTreeNode) => void): void; | ||
function get(rootPid: number, callback: (tree: ProcessTreeNode) => void, flag?: ProcessDataFlag): void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's call this flags
READY : Fixate node-pre-gyp
Adds optional flags parameter to control what information is fetched about a process. When memory bit is set, reports memory usage for each process in bytes.