about summary refs log tree commit diff
path: root/pkgs/development/web/deno/update/common.ts
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/web/deno/update/common.ts')
-rw-r--r--pkgs/development/web/deno/update/common.ts34
1 files changed, 12 insertions, 22 deletions
diff --git a/pkgs/development/web/deno/update/common.ts b/pkgs/development/web/deno/update/common.ts
index d8956b21d1639..1b4e3509ea7cd 100644
--- a/pkgs/development/web/deno/update/common.ts
+++ b/pkgs/development/web/deno/update/common.ts
@@ -3,12 +3,15 @@ interface GHRelease {
 }
 
 const decode = (buffer: Uint8Array) => new TextDecoder("utf-8").decode(buffer);
-const run = async (command: string, args: string[]) => {
-  const cmd = Deno.run(
-    { cmd: [command, ...args], stdout: "piped", stderr: "piped" },
-  );
+const decodeTrim = (b: Uint8Array) => decode(b).trimEnd();
+export const run = async (command: string, args: string[]) => {
+  const cmd = Deno.run({
+    cmd: [command, ...args],
+    stdout: "piped",
+    stderr: "piped",
+  });
   if (!(await cmd.status()).success) {
-    const error = await cmd.stderrOutput().then((b) => decode(b).trimEnd());
+    const error = await cmd.stderrOutput().then(decodeTrim);
     // Known error we can ignore
     if (error.includes("'allow-unsafe-native-code-during-evaluation'")) {
       // Extract the target sha256 out of the error
@@ -23,26 +26,16 @@ const run = async (command: string, args: string[]) => {
     }
     throw new Error(error);
   }
-  return cmd.output().then((b) => decode(b).trimEnd());
+  return cmd.output().then(decodeTrim);
 };
 
 // Exports
 export const versionRegExp = /\d+\.\d+\.\d+/;
-export const sha256RegExp = /[a-z0-9]{52}/;
-
-export async function commit(
-  name: string,
-  oldVer: string,
-  newVer: string,
-  files: string[],
-) {
-  await run("git", ["add", ...files]);
-  await run("git", ["commit", "-m", `${name}: ${oldVer} -> ${newVer}`]);
-}
+export const sha256RegExp = /[a-z0-9]{52}|sha256-.{44}/;
 
 export const getExistingVersion = async (filePath: string) =>
-  read(filePath).then((s) =>
-    s.match(genValueRegExp("version", versionRegExp))?.shift() || ""
+  read(filePath).then(
+    (s) => s.match(genValueRegExp("version", versionRegExp))?.shift() || "",
   );
 
 export const getLatestVersion = (owner: string, repo: string) =>
@@ -58,8 +51,5 @@ export const genValueRegExp = (key: string, regex: RegExp) =>
 export const logger = (name: string) =>
   (...a: any) => console.log(`[${name}]`, ...a);
 
-export const nixPrefetch = (args: string[]) => run("nix-prefetch", args);
-export const nixPrefetchURL = (args: string[]) => run("nix-prefetch-url", args);
-
 export const read = Deno.readTextFile;
 export const write = Deno.writeTextFile;