mirror of
https://github.com/pockethost/pockethost.git
synced 2025-03-30 15:08:30 +00:00
Add instance directory creation support
This commit is contained in:
parent
d510bc7461
commit
eba97d2481
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'
|
||||
|
Loading…
x
Reference in New Issue
Block a user