From 6e8a219c75cc701eb1aee294398bb55d3552584f Mon Sep 17 00:00:00 2001 From: Vicente Eduardo Ferrer Garcia Date: Thu, 16 Jan 2025 19:04:49 +0100 Subject: [PATCH] Add prune command for deleting all the deployments on startup. --- src/index.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/index.ts b/src/index.ts index 702ea0d..8a0b7a5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,6 +2,8 @@ import colors from 'colors'; import dotenv from 'dotenv'; +import fs from 'fs/promises'; +import path from 'path'; import { initializeAPI } from './api'; import { autoDeployApps } from './utils/autoDeploy'; import { appsDirectory } from './utils/config'; @@ -21,6 +23,14 @@ void (async (): Promise => { await ensureFolderExists(appsDirectory); + // Clear all deployments + if (args.includes('--prune')) { + // Delete appsDirectory files + for (const file of await fs.readdir(appsDirectory)) { + await fs.unlink(path.join(appsDirectory, file)); + } + } + await autoDeployApps(appsDirectory); const app = initializeAPI();