@@ -24,7 +24,6 @@ import { dedent } from "./utils/dedent";
2424import { createPatternMatcher } from "./utils/filesystem" ;
2525import type { StartDevWorkerOptions } from "./api" ;
2626import type { Config } from "./config" ;
27- import type { Assets } from "./config/environment" ;
2827import type { DeployArgs } from "./deploy" ;
2928import type { StartDevOptions } from "./dev" ;
3029import type { AssetConfig , RoutingConfig } from "@cloudflare/workers-shared" ;
@@ -310,12 +309,14 @@ function getAssetsBasePath(
310309 : path . resolve ( path . dirname ( config . configPath ?? "wrangler.toml" ) ) ;
311310}
312311
313- export type AssetsOptions = Pick < Assets , "directory" | "binding" > & {
312+ export type AssetsOptions = {
313+ directory : string ;
314+ binding ?: string ;
314315 routingConfig : RoutingConfig ;
315316 assetConfig : AssetConfig ;
316317} ;
317318
318- export function processAssetsArg (
319+ export function getAssetsOptions (
319320 args : { assets : string | undefined ; script ?: string } ,
320321 config : Config
321322) : AssetsOptions | undefined {
@@ -325,8 +326,20 @@ export function processAssetsArg(
325326 return ;
326327 }
327328
329+ const { directory, binding } = assets ;
330+
331+ if ( directory === undefined ) {
332+ throw new UserError (
333+ "The `assets` property in your configuration is missing the required `directory` property."
334+ ) ;
335+ }
336+
337+ if ( directory === "" ) {
338+ throw new UserError ( "`The assets directory cannot be an empty string." ) ;
339+ }
340+
328341 const assetsBasePath = getAssetsBasePath ( config , args . assets ) ;
329- const resolvedAssetsPath = path . resolve ( assetsBasePath , assets . directory ) ;
342+ const resolvedAssetsPath = path . resolve ( assetsBasePath , directory ) ;
330343
331344 if ( ! existsSync ( resolvedAssetsPath ) ) {
332345 const sourceOfTruthMessage = args . assets
@@ -339,7 +352,6 @@ export function processAssetsArg(
339352 ) ;
340353 }
341354
342- assets . directory = resolvedAssetsPath ;
343355 const routingConfig = {
344356 has_user_worker : Boolean ( args . script || config . main ) ,
345357 } ;
@@ -351,7 +363,8 @@ export function processAssetsArg(
351363 } ;
352364
353365 return {
354- ...assets ,
366+ directory : resolvedAssetsPath ,
367+ binding,
355368 routingConfig,
356369 assetConfig,
357370 } ;
0 commit comments