refactor(cli): rename the emigrate package to @emigrate/cli to be more in line with other tools

This commit is contained in:
Joakim Carlstein 2023-11-15 14:41:25 +01:00
parent 9f5abf727d
commit 0b78d5cf32
16 changed files with 34 additions and 11 deletions

View file

@ -0,0 +1,20 @@
import { cosmiconfig } from 'cosmiconfig';
import { type Config, type EmigrateConfig } from './types.js';
export const getConfig = async (command: 'up' | 'list' | 'new'): Promise<Config> => {
const explorer = cosmiconfig('emigrate');
const result = await explorer.search();
if (!result?.config) {
return {};
}
const { plugins, directory, template, ...commandsConfig } = result.config as EmigrateConfig;
if (commandsConfig[command]) {
return { plugins, directory, template, ...commandsConfig[command] };
}
return { plugins, directory, template };
};