Skip to content

Commit db3ce1b

Browse files
authored
fix: use setTimeout Promise (#58)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a custom sleep function for handling delays. - Added a new GitHub Actions workflow for continuous integration with Node.js 14. - **Bug Fixes** - Maintained existing error handling for retry logic in the waitPort function. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent b2cf1bb commit db3ce1b

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

.github/workflows/nodejs-14.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Node.js 14 CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Use Node.js
16+
uses: irby/setup-node-nvm@master
17+
with:
18+
node-version: '16.x'
19+
- run: npm install
20+
- run: npm run prepublishOnly
21+
- run: node -v
22+
- run: . /home/runner/mynvm/nvm.sh && nvm install 14 && nvm use 14 && node -v && node dist/commonjs/bin/detect-port.js

src/wait-port.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import { debuglog } from 'node:util';
2-
import { setTimeout as sleep } from 'node:timers/promises';
32
import detectPort from './detect-port.js';
43

54
const debug = debuglog('detect-port:wait-port');
65

6+
function sleep(ms: number) {
7+
return new Promise(resolve => {
8+
setTimeout(resolve, ms);
9+
});
10+
}
11+
712
export class WaitPortRetryError extends Error {
813
retries: number;
914
count: number;

0 commit comments

Comments
 (0)