File size: 962 Bytes
d739b1b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | // ์ค๋ช
๋ฌธ์: 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 };
|