mirror of
https://github.com/pockethost/pockethost.git
synced 2026-03-22 08:03:31 +00:00
Add instance directory creation support
This commit is contained in:
19
packages/pockethost/src/core/dir.ts
Normal file
19
packages/pockethost/src/core/dir.ts
Normal 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 })
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
export * from '../constants'
|
||||
export * from './asyncExecutionGuard'
|
||||
export * from './dir'
|
||||
export * from './discordAlert'
|
||||
export * from './env'
|
||||
export * from './exit'
|
||||
|
||||
Reference in New Issue
Block a user