forked from defunkt/toes
Delete git repo on app removal via app:delete event
This commit is contained in:
parent
be7a7bd35b
commit
0efc25834c
|
|
@ -1,6 +1,6 @@
|
|||
import { Hype } from '@because/hype'
|
||||
import { define, stylesToCSS } from '@because/forge'
|
||||
import { baseStyles, ToolScript, theme } from '@because/toes/tools'
|
||||
import { baseStyles, ToolScript, theme, on } from '@because/toes/tools'
|
||||
import { mkdirSync } from 'fs'
|
||||
import { mkdir, readdir, readlink, rm, stat } from 'fs/promises'
|
||||
import { join, resolve } from 'path'
|
||||
|
|
@ -406,6 +406,11 @@ async function withDeployLock<T>(repo: string, fn: () => Promise<T>): Promise<T>
|
|||
|
||||
mkdirSync(REPOS_DIR, { recursive: true })
|
||||
|
||||
on('app:delete', async ({ app: name }) => {
|
||||
const bare = repoPath(name)
|
||||
if (await dirExists(bare)) await rm(bare, { recursive: true, force: true })
|
||||
})
|
||||
|
||||
app.get('/ok', c => c.text('ok'))
|
||||
|
||||
app.get('/styles.css', c =>
|
||||
|
|
|
|||
|
|
@ -2,11 +2,10 @@ import { APPS_DIR, allApps, emit, registerApp, removeApp, restartApp, startApp }
|
|||
import { computeHash, generateManifest } from '../sync'
|
||||
import { loadGitignore } from '@gitignore'
|
||||
import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, symlinkSync, unlinkSync, watch, writeFileSync } from 'fs'
|
||||
import { dirname, join, resolve } from 'path'
|
||||
import { dirname, join } from 'path'
|
||||
import { Hype } from '@because/hype'
|
||||
|
||||
const MAX_VERSIONS = 5
|
||||
const REPOS_DIR = resolve(process.env.DATA_DIR ?? '.', 'repos')
|
||||
|
||||
interface FileChangeEvent {
|
||||
hash?: string
|
||||
|
|
@ -211,11 +210,6 @@ router.delete('/apps/:app', c => {
|
|||
|
||||
removeApp(appName)
|
||||
rmSync(appPath, { recursive: true })
|
||||
|
||||
// Remove bare git repo if one exists
|
||||
const repoPath = join(REPOS_DIR, `${appName}.git`)
|
||||
if (existsSync(repoPath)) rmSync(repoPath, { recursive: true })
|
||||
|
||||
return c.json({ ok: true })
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user