@ravshansbox/pi-next-issue 1.0.8 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.ts CHANGED
@@ -6,7 +6,7 @@ import { type Progress, Runner } from './src/runner.ts';
6
6
 
7
7
  type Launch = (cwd: string) => Promise<Runner>;
8
8
 
9
- type Holder = { runner?: Runner };
9
+ type Holder = { runner?: Runner; launching?: boolean };
10
10
 
11
11
  const KEY = Symbol.for('pi-next-issue');
12
12
  const STATUS_KEY = 'next-issue';
@@ -161,10 +161,11 @@ export function createExtension(launch: Launch) {
161
161
  const busy =
162
162
  current?.progress.status === 'running' || current?.progress.status === 'stopping';
163
163
  if (action === 'start') {
164
- if (busy) {
164
+ if (busy || holder().launching) {
165
165
  ctx.ui.notify('next-issue is running already', 'warning');
166
166
  return;
167
167
  }
168
+ holder().launching = true;
168
169
  let runner: Runner;
169
170
  try {
170
171
  runner = await launch(ctx.cwd);
@@ -174,6 +175,8 @@ export function createExtension(launch: Launch) {
174
175
  'error',
175
176
  );
176
177
  return;
178
+ } finally {
179
+ holder().launching = false;
177
180
  }
178
181
  holder().runner = runner;
179
182
  if (ctx.hasUI) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ravshansbox/pi-next-issue",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "Pi extension that works through GitHub issues in the background",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/github.ts CHANGED
@@ -273,6 +273,6 @@ export async function merge(
273
273
  if (Date.now() >= deadline) {
274
274
  return { merged: false, reason: 'the merge did not finish in time' };
275
275
  }
276
- await sleep(Math.min(POLL_MS, deadline - Date.now()), undefined, { signal });
276
+ await sleep(Math.max(0, Math.min(POLL_MS, deadline - Date.now())), undefined, { signal });
277
277
  }
278
278
  }