Enhance ESLint configuration to include support for .mjs and .cjs file types. Update ignored files patterns to ensure proper linting of project files. Refactor Vue component templates for improved readability and maintainability, including consistent formatting and structure across various components. Update error handling in save functions to prevent silent failures.
Some checks failed
Code Analysis (JS/Vue) / analyze (push) Failing after 52s
Some checks failed
Code Analysis (JS/Vue) / analyze (push) Failing after 52s
This commit is contained in:
31
server/utils/paths.js
Normal file
31
server/utils/paths.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
|
||||
function uniqueCandidates(candidates) {
|
||||
return [...new Set(candidates.filter(Boolean))]
|
||||
}
|
||||
|
||||
function hasServerDataDir(root) {
|
||||
return fs.existsSync(path.join(root, 'server', 'data'))
|
||||
}
|
||||
|
||||
export function resolveProjectRoot() {
|
||||
const envRoot = process.env.APP_ROOT ? process.env.APP_ROOT.trim() : ''
|
||||
const cwd = process.cwd()
|
||||
const parent = path.resolve(cwd, '..')
|
||||
|
||||
const candidates = uniqueCandidates([envRoot, cwd, parent])
|
||||
for (const root of candidates) {
|
||||
if (hasServerDataDir(root)) return root
|
||||
}
|
||||
|
||||
return cwd
|
||||
}
|
||||
|
||||
export function getProjectPath(...segments) {
|
||||
return path.join(resolveProjectRoot(), ...segments)
|
||||
}
|
||||
|
||||
export function getServerDataPath(...segments) {
|
||||
return getProjectPath('server', 'data', ...segments)
|
||||
}
|
||||
Reference in New Issue
Block a user