refactor(cli): re-use the Config type for the new command's parameters
This commit is contained in:
parent
0b78d5cf32
commit
70d2140dde
2 changed files with 4 additions and 11 deletions
|
|
@ -124,7 +124,7 @@ Examples:
|
|||
|
||||
try {
|
||||
const { default: newCommand } = await import('./new-command.js');
|
||||
await newCommand({ directory, template, plugins, name, extension });
|
||||
await newCommand({ directory, template, plugins, extension }, name);
|
||||
} catch (error) {
|
||||
if (error instanceof ShowUsageError) {
|
||||
console.error(error.message, '\n');
|
||||
|
|
|
|||
|
|
@ -2,18 +2,11 @@ import process from 'node:process';
|
|||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import { getTimestampPrefix, sanitizeMigrationName, loadPlugin, isGeneratorPlugin } from '@emigrate/plugin-tools';
|
||||
import { type Plugin, type GeneratorPlugin } from '@emigrate/plugin-tools/types';
|
||||
import { type GeneratorPlugin } from '@emigrate/plugin-tools/types';
|
||||
import { ShowUsageError } from './show-usage-error.js';
|
||||
import { type Config } from './types.js';
|
||||
|
||||
type NewCommandOptions = {
|
||||
directory?: string;
|
||||
template?: string;
|
||||
extension?: string;
|
||||
plugins: Array<string | Plugin>;
|
||||
name?: string;
|
||||
};
|
||||
|
||||
export default async function newCommand({ directory, template, plugins, name, extension }: NewCommandOptions) {
|
||||
export default async function newCommand({ directory, template, plugins = [], extension }: Config, name: string) {
|
||||
if (!directory) {
|
||||
throw new ShowUsageError('Missing required option: directory');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue