diff --git a/lib/main.ts b/lib/main.ts index 2952dae..0b01b29 100644 --- a/lib/main.ts +++ b/lib/main.ts @@ -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. @@ -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", diff --git a/lib/out.ts b/lib/out.ts index 7ac3771..0409d83 100644 --- a/lib/out.ts +++ b/lib/out.ts @@ -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`) } } }