refactor(cli): rename the emigrate package to @emigrate/cli to be more in line with other tools
This commit is contained in:
parent
9f5abf727d
commit
0b78d5cf32
16 changed files with 34 additions and 11 deletions
20
packages/cli/src/get-config.ts
Normal file
20
packages/cli/src/get-config.ts
Normal 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 };
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue