diff --git a/index.d.ts b/index.d.ts index e3291b0..4320407 100644 --- a/index.d.ts +++ b/index.d.ts @@ -24,7 +24,7 @@ declare type Options = { logLevel?: LogLevelDesc; } -declare function find(type: "name" | "pid" | "port", value: string | number | RegExp, strict?: boolean | Option): Promise<{ +declare function find(type: "name" | "pid" | "port", value: string | number | RegExp, strict?: boolean | Options): Promise<{ pid: number; ppid?: number; uid?: number; diff --git a/lib/find.js b/lib/find.js index a1e0530..ab79fc7 100644 --- a/lib/find.js +++ b/lib/find.js @@ -30,7 +30,8 @@ const findBy = { name (name, config) { return findProcess({ name: name, - config + config, + skipSelf: true }) } } diff --git a/lib/find_process.js b/lib/find_process.js index 2476f7f..cd56e71 100644 --- a/lib/find_process.js +++ b/lib/find_process.js @@ -233,7 +233,16 @@ function findProcess (cond) { find = finders[find] } - find(cond).then(resolve, reject) + find(cond).then((result) => { + if (cond.skipSelf) { + // skip find-process itself + const filteredResult = result.filter(item => item.pid !== process.pid) + + resolve(filteredResult) + } else { + resolve(result) + } + }, reject) }) } diff --git a/package.json b/package.json index 02dd0e4..ce6fa1d 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "/node_modules", "/doc", "/example", - "/test" + "/test", + "index.d.ts" ] }, "author": "zoujie ",