From 688e9cf778421426992d391a1ab2de1c54dcfc9e Mon Sep 17 00:00:00 2001 From: _Kerman Date: Sun, 10 Nov 2024 16:09:22 +0800 Subject: [PATCH] fix: `--download` option should affect `getDefine` (#1937) --- packages/slidev/node/cli.ts | 4 +--- packages/slidev/node/options.ts | 3 +++ packages/types/src/options.ts | 5 +++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/slidev/node/cli.ts b/packages/slidev/node/cli.ts index 686d2cadf3..8cdc34e8e3 100644 --- a/packages/slidev/node/cli.ts +++ b/packages/slidev/node/cli.ts @@ -351,9 +351,7 @@ cli.command( const { build } = await import('./commands/build') for (const entryFile of entry as unknown as string[]) { - const options = await resolveOptions({ entry: entryFile, theme, inspect }, 'build') - if (download && !options.data.config.download) - options.data.config.download = download + const options = await resolveOptions({ entry: entryFile, theme, inspect, download }, 'build') printInfo(options) await build( diff --git a/packages/slidev/node/options.ts b/packages/slidev/node/options.ts index 2e6d534684..38b041ea98 100644 --- a/packages/slidev/node/options.ts +++ b/packages/slidev/node/options.ts @@ -32,6 +32,9 @@ export async function resolveOptions( const addonRoots = await resolveAddons(config.addons) const roots = uniq([...themeRoots, ...addonRoots, rootsInfo.userRoot]) + if (entryOptions.download) + config.download ||= entryOptions.download + debug({ ...rootsInfo, ...entryOptions, diff --git a/packages/types/src/options.ts b/packages/types/src/options.ts index 120136b48c..ec27d6cc40 100644 --- a/packages/types/src/options.ts +++ b/packages/types/src/options.ts @@ -30,6 +30,11 @@ export interface SlidevEntryOptions { * Enable inspect plugin */ inspect?: boolean + + /** + * Build with --download option + */ + download?: boolean } export interface ResolvedSlidevOptions extends RootsInfo, SlidevEntryOptions {