Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/cli/cli/src/utils/forceThingExists.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import fs from "fs/promises";
import path from "path";

import logger from "@captain/logger";

const THING_PATH = path.join(process.cwd(), ".thing");
const HOOK_PATH = path.join(THING_PATH, "hooks");

export default async function forceThingExists() {
try {
await fs.access(THING_PATH);
} catch (error) {
logger.warn("No .thing directory found, creating one now.");
await fs.mkdir(THING_PATH);
}

try {
await fs.access(HOOK_PATH);
} catch (error) {
logger.warn("No .thing/hooks directory found, creating one now.");
await fs.mkdir(HOOK_PATH);
}
}