Skip to content

Commit

Permalink
feat: replace ps-tree with @webpod/ps, expose ps util (#742)
Browse files Browse the repository at this point in the history
* feat: replace ps-tree with @webpod/ps, expose `ps` util

* chore: linting
  • Loading branch information
antongolub authored Mar 26, 2024
1 parent 6b992f8 commit c2cda4a
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 116 deletions.
133 changes: 32 additions & 101 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
"@types/fs-extra": "^11.0.4",
"@types/minimist": "^1.2.5",
"@types/node": ">=20.11.19",
"@types/ps-tree": "^1.1.6",
"@types/which": "^3.0.3",
"@webpod/ps": "^0.0.0-beta.2",
"c8": "^7.13.0",
"chalk": "^5.3.0",
"dts-bundle-generator": "^9.3.1",
Expand All @@ -77,13 +77,12 @@
"minimist": "^1.2.8",
"node-fetch-native": "^1.6.2",
"prettier": "^2.8.8",
"ps-tree": "^1.2.0",
"tsd": "^0.30.7",
"typescript": "^5.0.4",
"typescript": "^5.4.3",
"webpod": "^0",
"which": "^3.0.0",
"yaml": "^2.4.1",
"zurk": "^0.0.31"
"zurk": "^0.0.32"
},
"publishConfig": {
"registry": "https://wombat-dressing-room.appspot.com"
Expand Down
6 changes: 3 additions & 3 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
buildCmd,
chalk,
which,
ps,
type ChalkInstance,
RequestInfo,
RequestInit,
Expand All @@ -33,7 +34,6 @@ import {
formatCmd,
noop,
parseDuration,
psTree,
quote,
quotePowerShell,
} from './util.js'
Expand Down Expand Up @@ -412,10 +412,10 @@ export class ProcessPromise extends Promise<ProcessOutput> {
throw new Error('Trying to kill a process without creating one.')
if (!this.child.pid) throw new Error('The process pid is undefined.')

let children = await psTree(this.child.pid)
let children = await ps.tree({ pid: this.child.pid, recursive: true })
for (const p of children) {
try {
process.kill(+p.PID, signal)
process.kill(+p.pid, signal)
} catch (e) {}
}
try {
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { ProcessPromise } from './core.js'

export * from './core.js'
export * from './goods.js'
export { minimist, chalk, fs, which, YAML, ssh } from './vendor.js'
export { minimist, chalk, fs, which, YAML, ssh, ps } from './vendor.js'

export { type Duration, quote, quotePowerShell } from './util.js'

Expand Down
4 changes: 1 addition & 3 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
// limitations under the License.

import { promisify } from 'node:util'
import { chalk, psTreeModule } from './vendor.js'

export const psTree = promisify(psTreeModule)
import { chalk } from './vendor.js'

export function noop() {}

Expand Down
2 changes: 1 addition & 1 deletion src/vendor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ export { type Options as GlobbyOptions } from 'globby'
export { default as chalk, type ChalkInstance } from 'chalk'
export { default as which } from 'which'
export { default as minimist } from 'minimist'
export { default as psTreeModule } from 'ps-tree'
export { default as ps } from '@webpod/ps'
export { ssh } from 'webpod'
2 changes: 1 addition & 1 deletion test/fixtures/ts-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"private": true,
"type": "module",
"dependencies": {
"typescript": "^4.7.3",
"typescript": "^5.0.0",
"zx": "*"
}
}
4 changes: 2 additions & 2 deletions test/fixtures/ts-project/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"compilerOptions": {
"outDir": "./build",
"target": "es2021",
"module": "esnext",
"moduleResolution": "node16",
"module": "nodenext",
"moduleResolution": "nodenext",
"allowSyntheticDefaultImports": true,
"strict": true
},
Expand Down

0 comments on commit c2cda4a

Please sign in to comment.