Skip to content

Commit

Permalink
Change way args are passed to cli packages (#9774)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewp authored Jan 22, 2024
1 parent eed0e87 commit 6c5f42d
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions packages/astro/src/cli/db/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import type { Arguments } from 'yargs-parser';
import { createLoggerFromFlags } from '../flags.js';
import { createLoggerFromFlags, flagsToAstroInlineConfig } from '../flags.js';
import { getPackage } from '../install-package.js';
import { resolveConfig } from '../../core/config/config.js';
import type { AstroConfig } from '../../@types/astro.js';

type DBPackage = {
cli: (args: { flags: Arguments, config: AstroConfig }) => unknown;
};

export async function db({ flags }: { flags: Arguments }) {
const logger = createLoggerFromFlags(flags);
const getPackageOpts = { skipAsk: flags.yes || flags.y, cwd: flags.root };
const dbPackage = await getPackage<any>('@astrojs/db', logger, getPackageOpts, []);
const dbPackage = await getPackage<DBPackage>('@astrojs/db', logger, getPackageOpts, []);

if (!dbPackage) {
logger.error(
Expand All @@ -17,6 +23,8 @@ export async function db({ flags }: { flags: Arguments }) {

const { cli } = dbPackage;

const [command, ...args] = flags._.slice(3).map((v) => v.toString());
await cli(command, args);
const inlineConfig = flagsToAstroInlineConfig(flags);
const { astroConfig } = await resolveConfig(inlineConfig, 'build');

await cli({flags, config: astroConfig});
}

0 comments on commit 6c5f42d

Please sign in to comment.