Last active
June 8, 2020 17:48
-
-
Save cstroliadavis/7a74aa32d2029d8d32e5d4a598cddf27 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {decodeUtf8} from './third_party.ts' | |
/** | |
* Gets the name of the git branch of the current working directory | |
* @returns {Promise<string>} | |
* | |
* @example | |
* // if on the main git branch | |
* console.log(await getGitBranch()); | |
* // output: master | |
*/ | |
export default async function getGitBranch(): Promise<string> { | |
const proc = Deno.run({ cmd: ['git', 'rev-parse', '--abbrev-ref', 'HEAD'], stdout: 'piped'}); | |
return (await decodeUtf8(await proc.output())).split('\n')[0]; | |
} | |
if (import.meta.main) { | |
console.log(await getGitBranch()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export * as path from "https://deno.land/std/path/mod.ts"; | |
export { decode as decodeUtf8 } from "https://deno.land/std/encoding/utf8.ts"; | |
export { ensureDir } from "https://deno.land/std/fs/ensure_dir.ts"; | |
export { exists as pathExists } from 'https://deno.land/std/fs/exists.ts' | |
export { serve } from "https://deno.land/std@0.55.0/http/server.ts"; | |
export { sprintf } from 'https://deno.land/std/fmt/printf.ts'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment