@nurix/nustack 0.10.0-dev.18 → 0.10.0-dev.20

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.
@@ -1,33 +0,0 @@
1
- import { execFile } from "node:child_process";
2
- import { mkdir } from "node:fs/promises";
3
- import os from "node:os";
4
- import path from "node:path";
5
- export const LANE_BRANCH_PREFIX = "nustack/lane-";
6
- export function lanesHome(env = process.env) {
7
- const override = env.NUSTACK_LANES_HOME;
8
- if (override && override !== "")
9
- return override;
10
- return path.join(os.homedir(), ".nustack", "lanes");
11
- }
12
- function git(args, cwd) {
13
- return new Promise((resolve) => {
14
- execFile("git", args, { cwd, timeout: 15_000 }, (error, stdout) => {
15
- resolve(error ? null : stdout.trim());
16
- });
17
- });
18
- }
19
- export async function createLaneWorktree(projectPath, laneId, env = process.env, isolate = false) {
20
- const inPlace = { worktreePath: projectPath, branch: null, isolated: false };
21
- if (!isolate)
22
- return inPlace;
23
- const isRepo = await git(["rev-parse", "--is-inside-work-tree"], projectPath);
24
- if (isRepo !== "true")
25
- return inPlace;
26
- const branch = `${LANE_BRANCH_PREFIX}${laneId}`;
27
- const worktreePath = path.join(lanesHome(env), "worktrees", laneId);
28
- await mkdir(path.dirname(worktreePath), { recursive: true });
29
- const added = await git(["worktree", "add", worktreePath, "-b", branch], projectPath);
30
- if (added === null)
31
- return inPlace;
32
- return { worktreePath, branch, isolated: true };
33
- }