@@ -79,9 +79,20 @@ async function resolveConfig(): Promise<
7979async function autoDetectEntryPoint (
8080 configEntryPoint ?: string ,
8181) : Promise < string > {
82+ // If config specifies entry point, use it (check this first, before src/ validation)
83+ if ( configEntryPoint ) {
84+ if ( ! existsSync ( configEntryPoint ) ) {
85+ error (
86+ `Entry point specified in deno.json does not exist: ${ configEntryPoint } ` ,
87+ ) ;
88+ Deno . exit ( 1 ) ;
89+ }
90+ return configEntryPoint ;
91+ }
92+
8293 const srcDir = "src" ;
8394
84- // Check if src/ exists
95+ // Check if src/ exists (only needed for auto-detection)
8596 if ( ! existsSync ( srcDir ) ) {
8697 error ( "No src/ directory found.\n" ) ;
8798 error ( "Create a TypeScript file in src/:" ) ;
@@ -102,17 +113,6 @@ async function autoDetectEntryPoint(
102113 Deno . exit ( 1 ) ;
103114 }
104115
105- // If config specifies entry point, use it
106- if ( configEntryPoint ) {
107- if ( ! existsSync ( configEntryPoint ) ) {
108- error (
109- `Entry point specified in deno.json does not exist: ${ configEntryPoint } ` ,
110- ) ;
111- Deno . exit ( 1 ) ;
112- }
113- return configEntryPoint ;
114- }
115-
116116 // Find .ts files in src/
117117 const tsFiles : string [ ] = [ ] ;
118118 for await ( const entry of Deno . readDir ( srcDir ) ) {
@@ -163,18 +163,34 @@ function inferFilename(entryPoint: string): string {
163163 return `${ fileName } .js` ;
164164}
165165
166- function inferOutputPath ( outputFilename : string ) : string {
166+ function inferOutputPath (
167+ outputFilename : string ,
168+ userSpecifiedFilename ?: string ,
169+ ) : string {
167170 // Derive extension name from filename for error messages
168171 const extensionName = basename ( outputFilename , extname ( outputFilename ) ) ;
169172
170173 // Find the extension directory by looking for _extension.yml
171174 const extensionsDir = "_extensions" ;
172175 if ( ! existsSync ( extensionsDir ) ) {
173176 error ( "No _extensions/ directory found.\n" ) ;
174- error (
175- "Extension projects must have an _extensions/ directory with _extension.yml." ,
176- ) ;
177- error ( "Create the extension structure:" ) ;
177+
178+ if ( userSpecifiedFilename ) {
179+ // User specified a filename in deno.json - offer path prefix option
180+ error (
181+ `You specified outputFile: "${ userSpecifiedFilename } " in deno.json.` ,
182+ ) ;
183+ error ( "To write to the current directory, use a path prefix:" ) ;
184+ error ( ` "outputFile": "./${ userSpecifiedFilename } "\n` ) ;
185+ error ( "Or create an extension structure:" ) ;
186+ } else {
187+ // Auto-detection mode - standard error
188+ error (
189+ "Extension projects must have an _extensions/ directory with _extension.yml." ,
190+ ) ;
191+ error ( "Create the extension structure:" ) ;
192+ }
193+
178194 error ( ` mkdir -p _extensions/${ extensionName } ` ) ;
179195 error ( ` touch _extensions/${ extensionName } /_extension.yml` ) ;
180196 Deno . exit ( 1 ) ;
@@ -248,7 +264,8 @@ async function bundle(
248264 // Check if it's just a filename (no path separators)
249265 if ( ! specifiedOutput . includes ( "/" ) && ! specifiedOutput . includes ( "\\" ) ) {
250266 // Just filename - infer directory from _extension.yml
251- outputPath = inferOutputPath ( specifiedOutput ) ;
267+ // Pass the user-specified filename for better error messages
268+ outputPath = inferOutputPath ( specifiedOutput , specifiedOutput ) ;
252269 } else {
253270 // Full path specified - use as-is
254271 outputPath = specifiedOutput ;
0 commit comments