Skip to content

Commit

Permalink
Fixes #4
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarred-Sumner committed Feb 12, 2021
1 parent b6d2d35 commit 4975aa9
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 68 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ This was inspired by github1s.com.

### Changelog

- `1.1.14`: Fix code-insiders and fix passing in editor manually when its `subl` or `code`.
- `1.1.13`: Use `Authorization` header instead of `access_token` query string.
- `1.1.12`: When available, also use github access token for fetching tarballs (instead of just search)
- `1.1.11`: When available, use github access token for github API requests to enable private repositories to work. To enable this, either set a `GITHUB_TOKEN` environment variable or if you've installed [hub](https://github.com/github/hub), it will automatically use `oauth_token` from `$HOME/.config/hub`. In other words, if you use `hub`, this should just work by default.
Expand Down
126 changes: 63 additions & 63 deletions bin/git-peek

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jarred/git-peek",
"version": "1.1.13",
"version": "1.1.14",
"author": "Jarred Sumner @Jarred-Sumner",
"description": "Quickly preview remote Git repositories in your local editor",
"bin": {
Expand Down
12 changes: 8 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import tmp from "tmp";
import { fetch } from "./fetch";
import which from "which";

// let editorsToTry = ["code", "subl", "code-insiders", "vim", "vi"];
let editorsToTry = ["code", "subl", "code-insiders", "vim", "vi"];

if (typeof Promise.any !== "function") {
require("promise-any-polyfill");
}
Expand Down Expand Up @@ -206,7 +209,9 @@ class Command {
OPTIONS
-e, --editor=editor [default: auto] editor to open with, possible values:
auto, code, vim, subl. By default, it will search
auto, ${editorsToTry.join(
", "
)}. By default, it will search
$EDITOR. If not found, it will try code, then subl,
then vim.
Expand Down Expand Up @@ -364,14 +369,11 @@ class Command {
!_editor || _editor === "auto" ? process.env.EDITOR : _editor;

if (!chosenEditor?.trim().length) {
let editorsToTry = ["code", "subl", "vim", "vi"];

for (let editor of editorsToTry) {
try {
chosenEditor = which.sync(editor);
if (chosenEditor.includes("code") || chosenEditor.includes("subl")) {
chosenEditor = `"` + chosenEditor + `"`;
chosenEditor += " --wait";
}
break;
} catch (exception) {}
Expand All @@ -385,13 +387,15 @@ class Command {
let editorMode = EditorMode.unknown;

if (chosenEditor.includes("code")) {
chosenEditor += " --wait";
editorMode = EditorMode.vscode;
editorSpecificCommands.push("--new-window");

if (specificFile) {
editorSpecificCommands.push(`-g "${path.resolve(openPath)}":0:0`);
}
} else if (chosenEditor.includes("subl")) {
chosenEditor += " --wait";
editorMode = EditorMode.sublime;
editorSpecificCommands.push("--new-window");

Expand Down

0 comments on commit 4975aa9

Please sign in to comment.