Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/nodejs-14.yml
Original file line number Diff line number Diff line change
@@ -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'
Comment on lines +16 to +18
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider using the official Node.js setup action

The workflow uses irby/setup-node-nvm@master which is a third-party action. For better security and reliability, consider using the official actions/setup-node action which also supports multiple Node.js versions.

-        uses: irby/setup-node-nvm@master
+        uses: actions/setup-node@v4
         with:
-          node-version: '16.x'
+          node-version: ['14.x', '16.x']

Committable suggestion skipped: line range outside the PR's diff.

- 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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add explicit test step

The workflow is missing an explicit test step. While prepublishOnly might run tests, it's better to have a dedicated test step for clarity.

Add this step after prepublishOnly:

      - name: Run tests
        run: npm test

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add error handling for detect-port binary execution

The workflow should handle potential failures when running the detect-port binary and provide meaningful error output.

-      - run: node dist/commonjs/bin/detect-port.js
+      - name: Test detect-port binary
+        run: |
+          set -e
+          if ! output=$(node dist/commonjs/bin/detect-port.js 2>&1); then
+            echo "Error running detect-port: $output"
+            exit 1
+          fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- run: node dist/commonjs/bin/detect-port.js
- name: Test detect-port binary
run: |
set -e
if ! output=$(node dist/commonjs/bin/detect-port.js 2>&1); then
echo "Error running detect-port: $output"
exit 1
fi

7 changes: 6 additions & 1 deletion src/wait-port.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Loading