git-worktree-utils 1.0.4 → 1.1.1
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/dist/add.js +7 -6
- package/dist/cli.js +4 -4
- package/dist/sync-env.js +2 -2
- package/package.json +1 -1
package/dist/add.js
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
import { execSync } from "child_process";
|
|
3
3
|
import { p as parseArgs, e as exitWithError, i as isBranchCheckedOut, g as getMainRepoRoot, c as copyEnvFiles } from "./utils-D1mQhe1g.js";
|
|
4
4
|
const args = parseArgs(process.argv.slice(2));
|
|
5
|
-
const dirName = args["dirName"];
|
|
6
5
|
const branchName = args["branchName"];
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const dirName = args["dirName"];
|
|
7
|
+
if (!branchName) {
|
|
8
|
+
exitWithError("Missing --branchName=...");
|
|
9
9
|
}
|
|
10
|
-
const branch = branchName
|
|
10
|
+
const branch = branchName;
|
|
11
|
+
const dir = dirName || branchName;
|
|
11
12
|
const { checkedOut, location } = isBranchCheckedOut(branch);
|
|
12
13
|
if (checkedOut) {
|
|
13
14
|
console.error(`Branch '${branch}' is already checked out at:`);
|
|
@@ -36,7 +37,7 @@ function branchExistsOnRemote(branchName2) {
|
|
|
36
37
|
return false;
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
|
-
const targetPath = `../${
|
|
40
|
+
const targetPath = `../${dir}`;
|
|
40
41
|
try {
|
|
41
42
|
console.log(`Creating worktree at ${targetPath} for branch ${branch}...`);
|
|
42
43
|
if (branchExistsLocally(branch)) {
|
|
@@ -54,5 +55,5 @@ Tip: Run \`git push -u origin ${branch}\` to push and set up tracking, otherwise
|
|
|
54
55
|
}
|
|
55
56
|
console.log("\nCopying .env files...");
|
|
56
57
|
const mainRoot = getMainRepoRoot();
|
|
57
|
-
const count = copyEnvFiles(mainRoot, `../${
|
|
58
|
+
const count = copyEnvFiles(mainRoot, `../${dir}`);
|
|
58
59
|
console.log(`Done copying ${count} .env file(s)`);
|
package/dist/cli.js
CHANGED
|
@@ -32,8 +32,8 @@ Commands:
|
|
|
32
32
|
sync-env Sync .env files to other worktrees
|
|
33
33
|
|
|
34
34
|
Options for 'add':
|
|
35
|
-
--
|
|
36
|
-
--
|
|
35
|
+
--branchName=<name> Branch name (required)
|
|
36
|
+
--dirName=<name> Directory name for the worktree (defaults to branchName)
|
|
37
37
|
|
|
38
38
|
Options for 'find':
|
|
39
39
|
--search=<term> Search term (case-insensitive)
|
|
@@ -57,8 +57,8 @@ Safety Features:
|
|
|
57
57
|
- Automatically copies .env files when creating worktrees
|
|
58
58
|
|
|
59
59
|
Examples:
|
|
60
|
-
wt add --
|
|
61
|
-
wt add --dirName=
|
|
60
|
+
wt add --branchName=feature/my-feature
|
|
61
|
+
wt add --branchName=feature/my-feature --dirName=my-feature
|
|
62
62
|
wt find --search=feature
|
|
63
63
|
wt sync-env --all
|
|
64
64
|
wt remove --dirName=old-feature
|
package/dist/sync-env.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { p as parseArgs, d as getCurrentWorktreeRoot, e as exitWithError, f as getWorktreeListPaths, c as copyEnvFiles } from "./utils-D1mQhe1g.js";
|
|
3
3
|
import { existsSync } from "fs";
|
|
4
|
-
import { join } from "path";
|
|
4
|
+
import { join, resolve } from "path";
|
|
5
5
|
const args = parseArgs(process.argv.slice(2));
|
|
6
6
|
const to = args["to"];
|
|
7
7
|
const all = args["all"];
|
|
@@ -18,7 +18,7 @@ if (to) {
|
|
|
18
18
|
if (!existsSync(targetPath)) {
|
|
19
19
|
exitWithError(`Worktree not found: ${targetPath}`);
|
|
20
20
|
}
|
|
21
|
-
const absPath =
|
|
21
|
+
const absPath = resolve(targetPath);
|
|
22
22
|
targets = [absPath];
|
|
23
23
|
} else if (all) {
|
|
24
24
|
targets = getWorktreeListPaths().filter((p) => p !== currentRoot);
|