This commit is contained in:
2026-02-08 20:28:59 +08:00
parent b5b5401cea
commit 67280227c1
3 changed files with 19 additions and 15 deletions

View File

@@ -41,6 +41,15 @@ export class ProcessOutput {
} }
} }
export async function execCommandAndStdout(
command: string,
args?: string[],
options?: Deno.CommandOptions,): Promise<string> {
const processOutput = await execCommand(command, args, options);
processOutput.assertSuccess();
return processOutput.stdout.trim();
}
export async function execCommand( export async function execCommand(
command: string, command: string,
args?: string[], args?: string[],

View File

@@ -98,12 +98,12 @@
}, },
"git-check.ts": { "git-check.ts": {
"script_name": "git-check.ts", "script_name": "git-check.ts",
"script_length": 3084, "script_length": 3040,
"script_sha256": "84ebf44e6aa0a46641f822b412b29f58c9585cce778ab3dce33e870505340214", "script_sha256": "f03171ce3129c63f35d55c69fe7e8e5f085739ad56887810284716d1f1c95a27",
"script_full_url": "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/single-scripts/git-check.ts", "script_full_url": "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/single-scripts/git-check.ts",
"single_script_file": true, "single_script_file": true,
"publish_time": 1770541896791, "publish_time": 1770541896791,
"update_time": 1770553485311 "update_time": 1770553736989
}, },
"helloworld-bun.ts": { "helloworld-bun.ts": {
"script_name": "helloworld-bun.ts", "script_name": "helloworld-bun.ts",

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env runts -- --allow-all #!/usr/bin/env runts -- --allow-all
import { import {
execCommand, execCommandAndStdout,
formatHumanTime, formatHumanTime,
log, log,
ProcessBar, ProcessBar,
@@ -10,12 +10,9 @@ import {
term, term,
uint8ArrayToHexString, uint8ArrayToHexString,
writeStringToFile, writeStringToFile,
} from "https://script.hatter.ink/@34/deno-commons-mod.ts"; } from "https://script.hatter.ink/@35/deno-commons-mod.ts";
import { import {getGitLocalRev, getGitRemoteRev,} from "https://script.hatter.ink/@0/deno-git-mod.ts";
getGitLocalRev, import {parseArgs} from "jsr:@std/cli/parse-args";
getGitRemoteRev,
} from "https://script.hatter.ink/@0/deno-git-mod.ts";
import { parseArgs } from "jsr:@std/cli/parse-args";
const MILLIS_OF_HOUR = 60 * 60 * 1000; const MILLIS_OF_HOUR = 60 * 60 * 1000;
@@ -26,9 +23,7 @@ async function sha256OfString(input: string): Promise<string> {
} }
async function getPwd(): Promise<string> { async function getPwd(): Promise<string> {
return (await execCommand("pwd")) return await execCommandAndStdout("pwd");
.assertSuccess()
.stdout.trim();
} }
interface GitCheckCache { interface GitCheckCache {
@@ -100,5 +95,5 @@ git-check.ts [--interval NUMBER-OF-HOURS]`);
await main(); await main();
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260208T202409+08:00.MEUCIQDQct1xYu1frnSk3uzu // @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260208T202755+08:00.MEQCID0gTH0EMJ32IuSwRD2G
// RZ5WHoOdBCzaMDAe16JIbKZlGAIgZ3gBrD8FIH+H6efI8C7mkyn3RjoAqa6PAz72KcX/d80= // WzpwUI7eCDHExlRBPmPizM49AiAJ0T2Haify9X26A2S9ve16kSHMI1SPYgoTbD1ho3b2Xw==