UNPKG

@opengis/fastify-table

Version:

core-plugins

27 lines (22 loc) 904 B
import fs from 'node:fs'; import path from 'node:path'; import config from '../../../../../config.js'; // import { existsSync } from 'fs'; let logDir = null; export default function getRootDir() { // absolute / relative path if (logDir) return logDir; const file = ['config.json', '/data/local/config.json'].find(el => (fs.existsSync(el) ? el : null)); const root = file === 'config.json' ? process.cwd() : '/data/local'; logDir = config.logDir || path.join(root, config.log?.dir || 'log'); console.log({ logDir }); return logDir; // windows debug support /* const customLogDir = process.cwd().includes(':') ? 'c:/data/local' : '/data/local'; // docker default path if (existsSync(customLogDir)) { return path.join(customLogDir, config.folder || '', 'log'); } // non-docker default path return path.join(config.root || '/data/local', config.folder || '', 'log'); */ }