@paleo/worktree-env 0.7.1 → 0.7.2

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.
@@ -79,6 +79,7 @@ async function runSetup(args, ctx, run, config) {
79
79
  scheme,
80
80
  });
81
81
  const setupCtx = ensureWorktree(args, ctx, run, config.worktreeDirName);
82
+ refuseIfFinalizePending(setupCtx, config.registryDir, args.force ?? false);
82
83
  const branch = getCurrentBranch(setupCtx.currentWorktree);
83
84
  const { port: slot, owner } = resolveAndRegisterSlot({
84
85
  slot: args.slot,
@@ -143,6 +144,20 @@ async function runSetup(args, ctx, run, config) {
143
144
  closeSync(logFd);
144
145
  return { slot };
145
146
  }
147
+ function refuseIfFinalizePending(ctx, registryDir, force) {
148
+ if (force)
149
+ return;
150
+ const registry = readSlots(ctx.mainWorktree, registryDir);
151
+ const resolvedCurrent = resolve(ctx.currentWorktree);
152
+ const found = Object.entries(registry.slots).find(([, e]) => resolve(e.worktree) === resolvedCurrent && e.status === "pending");
153
+ if (!found)
154
+ return;
155
+ const [slotPort] = found;
156
+ console.error(`Error: Setup is already in progress for slot ${slotPort}. ` +
157
+ `Run 'setup-worktree --wait --slot ${slotPort}' to wait for it to finish (or fail), ` +
158
+ "then retry. Use --force to bypass.");
159
+ process.exit(1);
160
+ }
146
161
  async function runFinalize(args, config) {
147
162
  const slot = Number(args.__finalize);
148
163
  const ctx = detectWorktree();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paleo/worktree-env",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "description": "Worktree-based concurrent local environment kernel.",
5
5
  "keywords": [
6
6
  "worktree",