@shivanshshrivas/gwit 0.1.0 → 0.1.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.
- package/README.md +1 -1
- package/dist/index.cjs +14 -8
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -24,6 +24,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
));
|
|
25
25
|
|
|
26
26
|
// src/index.ts
|
|
27
|
+
var fs8 = __toESM(require("fs"));
|
|
28
|
+
var path6 = __toESM(require("path"));
|
|
27
29
|
var import_commander = require("commander");
|
|
28
30
|
|
|
29
31
|
// src/types.ts
|
|
@@ -171,11 +173,11 @@ function _parseWorktreePorcelain(output) {
|
|
|
171
173
|
const blocks = output.trim().split(/\n\n+/);
|
|
172
174
|
return blocks.filter(Boolean).map((block) => {
|
|
173
175
|
const lines = block.split("\n");
|
|
174
|
-
const
|
|
176
|
+
const path7 = lines.find((l) => l.startsWith("worktree "))?.slice(9) ?? "";
|
|
175
177
|
const head = lines.find((l) => l.startsWith("HEAD "))?.slice(5) ?? "";
|
|
176
178
|
const branchLine = lines.find((l) => l.startsWith("branch "));
|
|
177
179
|
const branch = branchLine ? branchLine.slice(7).replace("refs/heads/", "") : null;
|
|
178
|
-
return { path:
|
|
180
|
+
return { path: path7, head, branch };
|
|
179
181
|
}).filter((w) => w.path.length > 0);
|
|
180
182
|
}
|
|
181
183
|
function isGitRepo() {
|
|
@@ -579,12 +581,13 @@ var import_child_process3 = require("child_process");
|
|
|
579
581
|
var TERMINAL_EDITORS = /* @__PURE__ */ new Set(["vim", "nvim", "vi", "nano", "emacs"]);
|
|
580
582
|
function launchEditor(editor, worktreePath) {
|
|
581
583
|
if (TERMINAL_EDITORS.has(editor)) {
|
|
582
|
-
(0, import_child_process3.spawnSync)(editor, [worktreePath], { stdio: "inherit" });
|
|
584
|
+
(0, import_child_process3.spawnSync)(editor, [worktreePath], { stdio: "inherit", shell: true });
|
|
583
585
|
return;
|
|
584
586
|
}
|
|
585
587
|
const child = (0, import_child_process3.spawn)(editor, [worktreePath], {
|
|
586
588
|
detached: true,
|
|
587
|
-
stdio: "ignore"
|
|
589
|
+
stdio: "ignore",
|
|
590
|
+
shell: true
|
|
588
591
|
});
|
|
589
592
|
child.on("error", () => {
|
|
590
593
|
ui.warn(`Editor '${editor}' not found in PATH.`);
|
|
@@ -839,9 +842,9 @@ function _detectAppName(mainPath) {
|
|
|
839
842
|
const pkgPath = path5.join(mainPath, "package.json");
|
|
840
843
|
if (fs6.existsSync(pkgPath)) {
|
|
841
844
|
try {
|
|
842
|
-
const
|
|
843
|
-
if (
|
|
844
|
-
return
|
|
845
|
+
const pkg2 = JSON.parse(fs6.readFileSync(pkgPath, "utf-8"));
|
|
846
|
+
if (pkg2.name && pkg2.name.trim().length > 0) {
|
|
847
|
+
return pkg2.name.replace(/^@[^/]+\//, "").trim();
|
|
845
848
|
}
|
|
846
849
|
} catch {
|
|
847
850
|
}
|
|
@@ -1179,8 +1182,11 @@ function syncCommand(branch) {
|
|
|
1179
1182
|
}
|
|
1180
1183
|
|
|
1181
1184
|
// src/index.ts
|
|
1185
|
+
var pkg = JSON.parse(
|
|
1186
|
+
fs8.readFileSync(path6.join(__dirname, "..", "package.json"), "utf-8")
|
|
1187
|
+
);
|
|
1182
1188
|
var program = new import_commander.Command();
|
|
1183
|
-
program.name("gwit").description("Fully isolated git worktrees for parallel development").version(
|
|
1189
|
+
program.name("gwit").description("Fully isolated git worktrees for parallel development").version(pkg.version);
|
|
1184
1190
|
program.argument("[branch]", "Branch name (local or remote)").option("-b", "Create a new branch from HEAD").option("--editor <name>", "Override editor for this invocation").option("--no-editor", "Skip opening editor").option("--no-commands", "Skip .gwitcommand execution").action(async (branch, options) => {
|
|
1185
1191
|
if (!branch) {
|
|
1186
1192
|
program.help();
|