Skip to content

Commit

Permalink
fix(setup): Create artifacts folder if it doesn't already exist (#115)
Browse files Browse the repository at this point in the history
Fixes OGBE-66

This is really only applicable for the first time starting open-source development, but it's good to have that more streamined.
  • Loading branch information
NathanFlurry committed Mar 6, 2024
2 parents 3d1dd89 + 9ef3430 commit 6955079
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/artifacts/build_runtime_archive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ for (const file of files) {
archiveFiles[file] = await Deno.readTextFile(join(rootSrc, file));
}


// Create artifacts folder if it doesn't already exist
await Deno.mkdir(join(rootSrc, "artifacts"), { recursive: true });

// Write schema to file
await Deno.writeTextFile(
join(rootSrc, "artifacts", "runtime_archive.json"),
JSON.stringify(archiveFiles),
Expand Down
8 changes: 6 additions & 2 deletions src/artifacts/build_schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
//
// Generates schema JSON from the module & project config

import { join } from "../deps.ts";
import { tjs } from "./deps.ts";
import { dirname as parent, join } from "../deps.ts";

const dirname = import.meta.dirname;
if (!dirname) throw new Error("Missing dirname");

await Deno.mkdir(join(dirname, "..", "..", "artifacts")).catch(e => {
await Deno.mkdir(join(dirname, "..", "..", "artifacts")).catch((e) => {
if (!(e instanceof Deno.errors.AlreadyExists)) throw e;
});

Expand Down Expand Up @@ -70,5 +70,9 @@ for (const { name, type } of CONFIGS) {
});
if (schema == null) throw new Error("Failed to generate schema");

// Create artifacts folder if it doesn't already exist
await Deno.mkdir(parent(schemaPath), { recursive: true });

// Write schema to file
await Deno.writeTextFile(schemaPath, JSON.stringify(schema, null, "\t"));
}

0 comments on commit 6955079

Please sign in to comment.