Skip to content

Commit 0d3c129

Browse files
fix: address PR review comments
- Bump coverage thresholds from 70% to 80% in bunfig.toml - Fix shebang regex over-matching by removing multiline flag in build.ts - Add console.warn for silent catch in getExternalDependencies - Make second shebang regex more conservative for bundled modules - Use turbo:build in CI workflow to build all workspace packages - Add actions:write permission to release workflow for workflow dispatch - Use targeted signal listener cleanup in test setup
1 parent 0d80a6d commit 0d3c129

5 files changed

Lines changed: 23 additions & 10 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ jobs:
174174
timeout-minutes: 5
175175

176176
- name: Build
177-
run: bun run build
177+
run: bun run turbo:build
178178
env:
179179
NODE_ENV: production
180180
FORCE_COLOR: 1

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ permissions:
1212
contents: write
1313
pull-requests: write
1414
id-token: write
15+
actions: write
1516

1617
env:
1718
BUN_VERSION: 1.2.6

bunfig.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ preload = ["./tests/setup.ts"]
99
coverage = true
1010

1111
# Coverage thresholds
12-
coverageThreshold = { line = 70, function = 70, statement = 70 }
12+
coverageThreshold = { line = 80, function = 80, statement = 80 }
1313

1414
# Test timeouts
1515
timeout = 10000

scripts/build.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ function getExternalDependencies(): string[] {
101101
];
102102
// Keep npm packages external, but bundle @tm/* workspace packages
103103
return allDeps.filter((dep) => !dep.startsWith('@tm/'));
104-
} catch {
104+
} catch (error) {
105+
console.warn('Could not read package.json for external dependencies:', error);
105106
return [];
106107
}
107108
}
@@ -149,9 +150,9 @@ const taskMasterPath = join(distDir, 'task-master.js');
149150
function ensureShebang(content: string): string {
150151
const shebang = '#!/usr/bin/env node\n';
151152
// Remove any existing shebangs (there might be multiple from bundling)
152-
let cleaned = content.replace(/^(#!.*\n)+/gm, '');
153-
// Also handle shebangs that appear after the first line
154-
cleaned = cleaned.replace(/\n#!\/usr\/bin\/env node\n/g, '\n');
153+
let cleaned = content.replace(/^(#!.*\n)+/, '');
154+
// Also handle shebangs that appear after the first line (from bundled modules)
155+
cleaned = cleaned.replace(/\n(#!\/usr\/bin\/env node\n)+/g, '\n');
155156
return shebang + cleaned;
156157
}
157158

tests/setup.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,26 @@ if (process.env.SILENCE_CONSOLE === 'true') {
6161
};
6262
}
6363

64+
// Track original listener counts to restore only what we added
65+
const originalListenerCounts: Record<string, number> = {
66+
SIGINT: process.listenerCount('SIGINT'),
67+
SIGTERM: process.listenerCount('SIGTERM'),
68+
SIGHUP: process.listenerCount('SIGHUP'),
69+
};
70+
6471
// Clean up signal-exit listeners after all tests to prevent open handle warnings
6572
// This is needed because packages like proper-lockfile register signal handlers
6673
afterAll(async () => {
6774
// Give any pending async operations time to complete
6875
await new Promise((resolve) => setImmediate(resolve));
6976

70-
// Clean up any registered signal handlers from signal-exit
71-
const listeners = ['SIGINT', 'SIGTERM', 'SIGHUP'] as const;
72-
for (const signal of listeners) {
73-
process.removeAllListeners(signal);
77+
// Remove only listeners added after setup, preserving framework/application listeners
78+
for (const [signal, originalCount] of Object.entries(originalListenerCounts)) {
79+
const currentListeners = process.listeners(signal as NodeJS.Signals);
80+
const addedCount = currentListeners.length - originalCount;
81+
for (let i = 0; i < addedCount; i++) {
82+
const listener = currentListeners[currentListeners.length - 1 - i];
83+
process.removeListener(signal, listener as (...args: unknown[]) => void);
84+
}
7485
}
7586
});

0 commit comments

Comments
 (0)