Skip to content

Commit 5e6fae8

Browse files
committed
feat: replace ps-tree with @webpod/ps, expose ps util
1 parent 6b992f8 commit 5e6fae8

File tree

8 files changed

+44
-116
lines changed

8 files changed

+44
-116
lines changed

package-lock.json

+32-101
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@
6262
"@types/fs-extra": "^11.0.4",
6363
"@types/minimist": "^1.2.5",
6464
"@types/node": ">=20.11.19",
65-
"@types/ps-tree": "^1.1.6",
6665
"@types/which": "^3.0.3",
66+
"@webpod/ps": "^0.0.0-beta.2",
6767
"c8": "^7.13.0",
6868
"chalk": "^5.3.0",
6969
"dts-bundle-generator": "^9.3.1",
@@ -77,13 +77,12 @@
7777
"minimist": "^1.2.8",
7878
"node-fetch-native": "^1.6.2",
7979
"prettier": "^2.8.8",
80-
"ps-tree": "^1.2.0",
8180
"tsd": "^0.30.7",
82-
"typescript": "^5.0.4",
81+
"typescript": "^5.4.3",
8382
"webpod": "^0",
8483
"which": "^3.0.0",
8584
"yaml": "^2.4.1",
86-
"zurk": "^0.0.31"
85+
"zurk": "^0.0.32"
8786
},
8887
"publishConfig": {
8988
"registry": "https://wombat-dressing-room.appspot.com"

src/core.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
buildCmd,
2323
chalk,
2424
which,
25+
ps,
2526
type ChalkInstance,
2627
RequestInfo,
2728
RequestInit,
@@ -33,7 +34,6 @@ import {
3334
formatCmd,
3435
noop,
3536
parseDuration,
36-
psTree,
3737
quote,
3838
quotePowerShell,
3939
} from './util.js'
@@ -412,10 +412,10 @@ export class ProcessPromise extends Promise<ProcessOutput> {
412412
throw new Error('Trying to kill a process without creating one.')
413413
if (!this.child.pid) throw new Error('The process pid is undefined.')
414414

415-
let children = await psTree(this.child.pid)
415+
let children = await ps.tree({pid: this.child.pid, recursive: true})
416416
for (const p of children) {
417417
try {
418-
process.kill(+p.PID, signal)
418+
process.kill(+p.pid, signal)
419419
} catch (e) {}
420420
}
421421
try {

src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { ProcessPromise } from './core.js'
1616

1717
export * from './core.js'
1818
export * from './goods.js'
19-
export { minimist, chalk, fs, which, YAML, ssh } from './vendor.js'
19+
export { minimist, chalk, fs, which, YAML, ssh, ps } from './vendor.js'
2020

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

src/util.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
// limitations under the License.
1414

1515
import { promisify } from 'node:util'
16-
import { chalk, psTreeModule } from './vendor.js'
17-
18-
export const psTree = promisify(psTreeModule)
16+
import { chalk } from './vendor.js'
1917

2018
export function noop() {}
2119

src/vendor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@ export { type Options as GlobbyOptions } from 'globby'
5454
export { default as chalk, type ChalkInstance } from 'chalk'
5555
export { default as which } from 'which'
5656
export { default as minimist } from 'minimist'
57-
export { default as psTreeModule } from 'ps-tree'
57+
export { default as ps } from '@webpod/ps'
5858
export { ssh } from 'webpod'

test/fixtures/ts-project/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"private": true,
33
"type": "module",
44
"dependencies": {
5-
"typescript": "^4.7.3",
5+
"typescript": "^5.0.0",
66
"zx": "*"
77
}
88
}

test/fixtures/ts-project/tsconfig.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"compilerOptions": {
33
"outDir": "./build",
44
"target": "es2021",
5-
"module": "esnext",
6-
"moduleResolution": "node16",
5+
"module": "nodenext",
6+
"moduleResolution": "nodenext",
77
"allowSyntheticDefaultImports": true,
88
"strict": true
99
},

0 commit comments

Comments
 (0)