From 413d79932fcf3e80188541850ad8f55d634bed5d Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Sun, 8 Dec 2024 23:42:24 +0800 Subject: [PATCH 1/5] fix: use setTimeout Promise --- src/wait-port.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/wait-port.ts b/src/wait-port.ts index 82809a9..093b31a 100644 --- a/src/wait-port.ts +++ b/src/wait-port.ts @@ -1,9 +1,14 @@ import { debuglog } from 'node:util'; -import { setTimeout as sleep } from 'node:timers/promises'; import detectPort from './detect-port.js'; const debug = debuglog('detect-port:wait-port'); +function sleep(ms: number) { + return new Promise(resolve => { + setTimeout(resolve, ms); + }); +} + export class WaitPortRetryError extends Error { retries: number; count: number; From 3e2eefcd4e46682c4ba4955d6a827cc32e5cc51c Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Sun, 8 Dec 2024 23:47:43 +0800 Subject: [PATCH 2/5] test on Node.js 14 --- .github/workflows/nodejs-14.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/nodejs-14.yml diff --git a/.github/workflows/nodejs-14.yml b/.github/workflows/nodejs-14.yml new file mode 100644 index 0000000..8955228 --- /dev/null +++ b/.github/workflows/nodejs-14.yml @@ -0,0 +1,24 @@ +name: Node.js 14 CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Use Node.js + uses: irby/setup-node-nvm@master + with: + node-version: '16.x' + - run: npm install + - run: npm run prepublishOnly + - run: node -v + - run: nvm install 14 && nvm use 14 + - run: node -v + - run: node dist/commonjs/bin/detect-port.js From 7b11895a83523963bec0d13a6389b3c22e74dea3 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Sun, 8 Dec 2024 23:50:58 +0800 Subject: [PATCH 3/5] f --- .github/workflows/nodejs-14.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/nodejs-14.yml b/.github/workflows/nodejs-14.yml index 8955228..32f6371 100644 --- a/.github/workflows/nodejs-14.yml +++ b/.github/workflows/nodejs-14.yml @@ -19,6 +19,7 @@ jobs: - run: npm install - run: npm run prepublishOnly - run: node -v + - run: . /home/runner/mynvm/nvm.sh - run: nvm install 14 && nvm use 14 - run: node -v - run: node dist/commonjs/bin/detect-port.js From 1f947ef47ea80ebdde2a65b142aab0470cb25137 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Sun, 8 Dec 2024 23:52:20 +0800 Subject: [PATCH 4/5] f --- .github/workflows/nodejs-14.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/nodejs-14.yml b/.github/workflows/nodejs-14.yml index 32f6371..eab0097 100644 --- a/.github/workflows/nodejs-14.yml +++ b/.github/workflows/nodejs-14.yml @@ -19,7 +19,6 @@ jobs: - run: npm install - run: npm run prepublishOnly - run: node -v - - run: . /home/runner/mynvm/nvm.sh - - run: nvm install 14 && nvm use 14 + - run: . /home/runner/mynvm/nvm.sh && nvm install 14 && nvm use 14 - run: node -v - run: node dist/commonjs/bin/detect-port.js From 93ee00074760e339be5d13124a03621583bca12f Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Sun, 8 Dec 2024 23:55:07 +0800 Subject: [PATCH 5/5] f --- .github/workflows/nodejs-14.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/nodejs-14.yml b/.github/workflows/nodejs-14.yml index eab0097..25ed7a8 100644 --- a/.github/workflows/nodejs-14.yml +++ b/.github/workflows/nodejs-14.yml @@ -19,6 +19,4 @@ jobs: - run: npm install - run: npm run prepublishOnly - run: node -v - - run: . /home/runner/mynvm/nvm.sh && nvm install 14 && nvm use 14 - - run: node -v - - run: node dist/commonjs/bin/detect-port.js + - run: . /home/runner/mynvm/nvm.sh && nvm install 14 && nvm use 14 && node -v && node dist/commonjs/bin/detect-port.js