Skip to content

Commit f8362f5

Browse files
committed
🐛 FIX: Correct build:docs script bugs
An error when running box run-script build:docs because variables.exportsDir doesn't exist. The directoryCreate( outputDir ) is worse than useless, since DocBox creates this dir for you, and this code creates the wrong directory anyway! (it creates .tmp/apidocs/ inside the build/ directory, which is not where it should be.)
1 parent abed498 commit f8362f5

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

build/Build.cfc

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,7 @@ component {
130130
)
131131
.toConsole();
132132

133-
// Prepare exports directory
134-
variables.exportsDir = variables.artifactsDir & "/#projectName#/#arguments.version#";
135-
directoryCreate( variables.exportsDir, true, true );
133+
ensureExportDir( argumentCollection = arguments );
136134

137135
// Project Build Dir
138136
variables.projectBuildDir = variables.buildDir & "/#projectName#";
@@ -200,11 +198,12 @@ component {
200198
version = "1.0.0",
201199
outputDir = ".tmp/apidocs"
202200
){
201+
ensureExportDir( argumentCollection = arguments );
202+
203203
// Create project mapping
204204
fileSystemUtil.createMapping( arguments.projectName, variables.cwd );
205205
// Generate Docs
206206
print.greenLine( "Generating API Docs, please wait..." ).toConsole();
207-
directoryCreate( arguments.outputDir, true, true );
208207

209208
command( "docbox generate" )
210209
.params(
@@ -315,4 +314,18 @@ component {
315314
return ( createObject( "java", "java.lang.System" ).getProperty( "cfml.cli.exitCode" ) ?: 0 );
316315
}
317316

317+
/**
318+
* Ensure the export directory exists at artifacts/NAME/VERSION/
319+
*/
320+
private function ensureExportDir(
321+
required projectName,
322+
version = "1.0.0"
323+
){
324+
if ( structKeyExists( variables, "exportsDir" ) && directoryExists( variables.exportsDir ) ){
325+
return;
326+
}
327+
// Prepare exports directory
328+
variables.exportsDir = variables.artifactsDir & "/#projectName#/#arguments.version#";
329+
directoryCreate( variables.exportsDir, true, true );
330+
}
318331
}

0 commit comments

Comments
 (0)