bada-terminal / src /utils /opencode-database-path.js
VanyaJ's picture
Release BADA Terminal v2.1.0 (Enterprise Ontology, NVIDIA auto-ontology, Release Preflight)
d739b1b verified
Raw History Blame Contribute Delete
962 Bytes
// ์„ค๋ช… ๋ฌธ์„œ: docs/specs/cli-runtime-initialization.md (v1.1.0)
const path = require('path');
function environmentValue(env, name) {
return env[name] ?? (process.platform === 'win32' ? env[Object.keys(env).find(key => key.toUpperCase() === name)] : undefined);
}
function selectedDatabase(dataDirectory, setting) {
if (!setting) return { kind: 'default', file: path.join(dataDirectory, 'opencode.db') };
if (setting === ':memory:') return { kind: 'memory', file: null };
if (typeof setting !== 'string' || setting.includes('\0')) throw new Error('Invalid OpenCode database path');
// CLI์™€ ๋™์ผํ•˜๊ฒŒ ์ƒ๋Œ€ ๊ฒฝ๋กœ๋Š” cwd๊ฐ€ ์•„๋‹Œ OpenCode ๋ฐ์ดํ„ฐ ๋””๋ ‰ํ„ฐ๋ฆฌ์—์„œ ํ•ด์„ํ•œ๋‹ค.
const file = path.resolve(dataDirectory, setting);
if (file === path.parse(file).root) throw new Error('OpenCode database must be a file, not a filesystem root');
return { kind: 'custom', file };
}
module.exports = { environmentValue, selectedDatabase };