@@ -2,14 +2,15 @@ import { mkdirSync, type Stats, statSync } from "node:fs";
22import { resolve } from "node:path" ;
33import { parseArgs } from "node:util" ;
44
5- import { CacheBindingMode } from "./build/utils/index.js" ;
5+ import type { CacheBindingMode } from "./build/utils/index.js" ;
6+ import { isCacheBindingMode } from "./build/utils/index.js" ;
67
78export function getArgs ( ) : {
89 skipNextBuild : boolean ;
910 skipWranglerConfigCheck : boolean ;
1011 outputDir ?: string ;
1112 minify : boolean ;
12- populateCache ?: { mode : "local" | "remote" ; onlyPopulate : boolean } ;
13+ populateCache ?: { mode : CacheBindingMode ; onlyPopulate : boolean } ;
1314} {
1415 const { skipBuild, skipWranglerConfigCheck, output, noMinify, populateCache, onlyPopulateCache } =
1516 parseArgs ( {
@@ -50,7 +51,7 @@ export function getArgs(): {
5051
5152 if (
5253 ( populateCache !== undefined || onlyPopulateCache ) &&
53- ( ! populateCache ?. length || ! [ "local" , "remote" ] . includes ( populateCache ) )
54+ ( ! populateCache ?. length || ! isCacheBindingMode ( populateCache ) )
5455 ) {
5556 throw new Error ( `Error: missing mode for populate cache flag, expected 'local' | 'remote'` ) ;
5657 }
@@ -62,9 +63,7 @@ export function getArgs(): {
6263 skipWranglerConfigCheck ||
6364 [ "1" , "true" , "yes" ] . includes ( String ( process . env . SKIP_WRANGLER_CONFIG_CHECK ) ) ,
6465 minify : ! noMinify ,
65- populateCache : populateCache
66- ? { mode : populateCache as CacheBindingMode , onlyPopulate : ! ! onlyPopulateCache }
67- : undefined ,
66+ populateCache : populateCache ? { mode : populateCache , onlyPopulate : ! ! onlyPopulateCache } : undefined ,
6867 } ;
6968}
7069
0 commit comments