Skip to content

Commit

Permalink
Polish
Browse files Browse the repository at this point in the history
  • Loading branch information
szhu committed Jun 12, 2019
1 parent 6394375 commit 23c5207
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/main.ts
Expand Up @@ -7,6 +7,7 @@ import {
gitFetchPrune,
} from "./git.ts"
import { out } from "./out.ts"
import { run } from "./run.ts"

export async function main(_args: string[]) {
// Print usage notes, wait for user to confirm.
Expand Down Expand Up @@ -49,6 +50,9 @@ export async function main(_args: string[]) {
])
Deno.exit(1)
}
// Hacky fix for the following error:
// error: cannot lock ref 'refs/remotes/origin/HEAD'
await run(["git", "update-ref", "-d", "refs/remotes/origin/HEAD"])
await gitFetchPrune("origin", [
"+refs/heads/*:refs/remotes/origin/*",
"+refs/pull/*/head:refs/remotes/origin/pull/*/head",
Expand Down
7 changes: 6 additions & 1 deletion lib/out.ts
Expand Up @@ -3,7 +3,12 @@ export function out(output: string | string[]) {
Deno.stdout.writeSync(new TextEncoder().encode(output))
} else {
for (let line of output) {
out(`${wordWrap(line, { width: 80, indent: "" })}\n`)
// Support hanging indents with little developer effort!
let [_line, firstLineIndent, text] = line.match(/^([^A-Za-z0-9]* |)(.*)$/)
let indent = firstLineIndent.replace(/[^ ]/g, " ")
let wrapped = wordWrap(text, { width: 80, indent })
wrapped = firstLineIndent + wrapped.slice(firstLineIndent.length)
out(`${wrapped}\n`)
}
}
}
Expand Down

0 comments on commit 23c5207

Please sign in to comment.