chore(git-config): uuidv4 generator

pull/252/head
Michael Brewer 1 year ago
parent 84caaa1455
commit d7d2e0594f
No known key found for this signature in database
GPG Key ID: D7A137BA1254AFC7

@ -2,6 +2,12 @@ import { readableStreamToText, spawn } from "bun";
import { afterEach, expect, it } from "bun:test"; import { afterEach, expect, it } from "bun:test";
import { readFile, unlink } from "fs/promises"; import { readFile, unlink } from "fs/promises";
function uuidv4() {
return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, c =>
(+c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> +c / 4).toString(16)
);
}
export const runContainer = async ( export const runContainer = async (
image: string, image: string,
init = "sleep infinity", init = "sleep infinity",
@ -173,7 +179,7 @@ export const runTerraformApply = async (
vars: Record<string, string>, vars: Record<string, string>,
env: Record<string, string> = {}, env: Record<string, string> = {},
): Promise<TerraformState> => { ): Promise<TerraformState> => {
const stateFile = `${dir}/${crypto.randomUUID()}.tfstate`; const stateFile = `${dir}/${uuidv4()}.tfstate`;
Object.keys(vars).forEach((key) => (env[`TF_VAR_${key}`] = vars[key])); Object.keys(vars).forEach((key) => (env[`TF_VAR_${key}`] = vars[key]));
const proc = spawn( const proc = spawn(
[ [

Loading…
Cancel
Save