Skip to content

Commit

Permalink
links
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarred-Sumner committed Feb 16, 2021
1 parent 68b8089 commit fa033b5
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 54 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ But there are also [precompiled binaries](https://github.com/Jarred-Sumner/git-p
- [Windows x64 – 1.3.12](https://github.com/Jarred-Sumner/git-peek/releases/download/1.3.12/git-peek.exe)
- [macOS x64 – 1.3.12](https://github.com/Jarred-Sumner/git-peek/releases/download/1.3.12/git-peek-macOS) (same as installing from homebrew)

**NEW**: [Try the chrome/firefox extension](https://github.com/Jarred-Sumner/1-click-from-github-to-editor). It adds an "Open" button to pull requests, files, and repositories, so you can read code with your editor without needing to copy-paste into the terminal. Note: vim and Linux are both not supported yet
**NEW**: [Try the chrome/firefox extension](https://github.com/Jarred-Sumner/1-click-from-github-to-editor). It adds a "Peek" button to pull requests, files, and repositories, so you can read code with your editor without needing to copy-paste into the terminal. Note: vim and Linux are both not supported yet

## Usage:

Expand Down
75 changes: 43 additions & 32 deletions bin/git-peek

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions bin/git-peek.map

Large diffs are not rendered by default.

67 changes: 48 additions & 19 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,24 +463,10 @@ OPTIONS
-h, --help show CLI help
ENVIRONMENT VARIABLES:
$EDITOR: ${process.env.EDITOR?.length ? process.env.EDITOR : "not set"}
$GITHUB_TOKEN: ${
process.env.GITHUB_TOKEN?.length
? new Array(process.env.GITHUB_TOKEN.length).fill("*").join("")
: "not set"
}
$GITHUB_BASE_DOMAIN: ${
process.env.GITHUB_BASE_DOMAIN?.length
? process.env.GITHUB_BASE_DOMAIN
: "not set"
}
$GITHUB_API_DOMAIN: ${
process.env.GITHUB_API_DOMAIN?.length
? process.env.GITHUB_API_DOMAIN
: "not set"
}
.env: ${DOTENV_EXISTS ? "✅" : "❌"} ${GIT_PEEK_ENV_PATH}
-env, --environment print location and current directory of environment
variables
${envHelp()}
For use with private GitHub repositories, set $GITHUB_TOKEN to a personal
access token. To persist it, store it in your shell or the .env shown above.
Expand All @@ -490,6 +476,10 @@ to the appropriate URLs.
`.trim(),
{
flags: {
environment: {
type: "boolean",
alias: "env",
},
fromscript: {
type: "boolean",
default: false,
Expand Down Expand Up @@ -600,6 +590,12 @@ to the appropriate URLs.

shouldKeep = cli.flags.keep;

if (cli.flags.environment) {
console.log(envHelp());
process.exit(0);
return;
}

if (
cli.flags.fromscript &&
process.env.SAY_DEBUG?.length &&
Expand Down Expand Up @@ -633,6 +629,10 @@ to the appropriate URLs.

if (url.includes("git-peek://")) {
url = url.replace("git-peek://", "").trim();

if (url.includes("noCDN")) {
ALLOW_JSDELIVR = false;
}
}

// url = url.replace("/blob/", "/tree/");
Expand Down Expand Up @@ -979,6 +979,35 @@ to the appropriate URLs.
}
}

function envHelp() {
return `
ENVIRONMENT VARIABLES:
.env file: ${DOTENV_EXISTS ? "✅" : "❌"} ${GIT_PEEK_ENV_PATH}
$EDITOR: ${process.env.EDITOR?.length ? process.env.EDITOR : "not set"}
$GITHUB_TOKEN: ${
process.env.GITHUB_TOKEN?.length
? new Array(process.env.GITHUB_TOKEN.length).fill("*").join("")
: "not set"
}
$GITHUB_BASE_DOMAIN: ${
process.env.GITHUB_BASE_DOMAIN?.length
? process.env.GITHUB_BASE_DOMAIN
: "github.com"
}
$GITHUB_API_DOMAIN: ${
process.env.GITHUB_API_DOMAIN?.length
? process.env.GITHUB_API_DOMAIN
: "api.github.com"
}
`;
}

process.on("unhandledRejection", exceptionLogger);
process.on("unhandledException", exceptionLogger);

Expand All @@ -988,6 +1017,6 @@ if (DOTENV_EXISTS) {

const GITHUB_BASE_DOMAIN = process.env.GITHUB_BASE_DOMAIN || "github.com";
const GITHUB_API_DOMAIN = process.env.GITHUB_API_DOMAIN || "api.github.com";
const ALLOW_JSDELIVR = GITHUB_API_DOMAIN === "api.github.com";
let ALLOW_JSDELIVR = GITHUB_API_DOMAIN === "api.github.com";
instance = new Command();
instance.run();

0 comments on commit fa033b5

Please sign in to comment.