Add instance directory creation support

This commit is contained in:
Ben Allfree 2024-11-15 03:07:06 -08:00
parent d510bc7461
commit eba97d2481
2 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,19 @@
import { existsSync, mkdirSync } from 'fs'
import { Logger } from '../common'
import { mkInstanceDataPath } from '../constants'
export function ensureInstanceDirectoryStructure(
instanceId: string,
logger: Logger,
) {
const { dbg } = logger
;['pb_data', 'pb_migrations', 'pb_public', 'logs', 'pb_hooks'].forEach(
(dir) => {
const path = mkInstanceDataPath(instanceId, dir)
if (!existsSync(path)) {
dbg(`Creating ${path}`)
mkdirSync(path, { recursive: true })
}
},
)
}

View File

@ -1,5 +1,6 @@
export * from '../constants'
export * from './asyncExecutionGuard'
export * from './dir'
export * from './discordAlert'
export * from './env'
export * from './exit'