fix(cli): clean up eager loading bug when initializing cli
This commit is contained in:
parent
a443868f8b
commit
3d20361355
5 changed files with 99 additions and 96 deletions
|
@ -5,7 +5,8 @@ import { fileURLToPath } from 'url';
|
|||
import dotenv from 'dotenv';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const CACHE_DIR = path.resolve(__dirname, '..', '.cache');
|
||||
const rootDir = path.resolve(__dirname, '..');
|
||||
const CACHE_DIR = path.join(rootDir, '.cache');
|
||||
const CONFIG_PATH = path.join(CACHE_DIR, 'config.json');
|
||||
const MEDIA_TYPES = ['movie', 'show'];
|
||||
const ASSET_TYPES = ['poster', 'backdrop'];
|
||||
|
@ -13,10 +14,7 @@ const ASSET_TYPES = ['poster', 'backdrop'];
|
|||
dotenv.config({ path: path.resolve(__dirname, '..', '..', '.env') });
|
||||
|
||||
export const initConfig = async () => {
|
||||
const existingConfig = await fs.pathExists(CONFIG_PATH)
|
||||
? await fs.readJson(CONFIG_PATH)
|
||||
: {};
|
||||
|
||||
const existingConfig = await fs.pathExists(CONFIG_PATH) ? await fs.readJson(CONFIG_PATH) : {};
|
||||
const config = { ...existingConfig };
|
||||
|
||||
if (config.storageDir) {
|
||||
|
@ -153,7 +151,7 @@ export const loadConfig = async () => {
|
|||
}
|
||||
|
||||
return await fs.readJson(CONFIG_PATH);
|
||||
}
|
||||
};
|
||||
|
||||
const fetchGlobals = async () => {
|
||||
const POSTGREST_URL = process.env.POSTGREST_URL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue