Skip to content

Commit d2c3217

Browse files
authored
Merge pull request #199 from ortus-boxlang/development
version bump
2 parents 40b70b3 + 8fcf300 commit d2c3217

File tree

4 files changed

+42
-24
lines changed

4 files changed

+42
-24
lines changed

build.gradle

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,22 +150,18 @@ project.ext.bumpVersion = {
150150
boolean minor = false,
151151
boolean patch = false,
152152
boolean beta = false,
153-
boolean rc = false ->
153+
boolean rc = false,
154+
property = "version" ->
154155

155156
def propertiesFile = file( './gradle.properties' );
156157
def properties = new Properties();
157158

158159
properties.load( propertiesFile.newDataInputStream() )
159160
def versionTarget = major ? 0 : minor ? 1 : beta ? 2 : 3
160161

161-
def currentVersion = properties.getProperty( 'version' )
162-
// 1.1.0 -> -> [ 1, 1, 0 ]
163-
// 1.0.0-beta1 -> [ 1, 0, 0-beta1 ]
164-
// 1.0.0-rc.1 -> [ 1, 0, 0-rc, 1 ]
162+
def currentVersion = properties.getProperty( property )
165163
def versionParts = currentVersion.split( '\\.' )
166-
if( !beta ){
167-
def newPathVersion = versionParts[ versionTarget ].toInteger() + 1
168-
}
164+
def newPathVersion = versionParts[ versionTarget ].toInteger() + 1
169165
def newVersion = '';
170166

171167
if( patch ){
@@ -184,7 +180,7 @@ project.ext.bumpVersion = {
184180
newVersion = "${versionParts[ 0 ]}.${versionParts[ 1 ]}.${versionParts[ 2 ]}.${newPathVersion}"
185181
}
186182

187-
properties.setProperty( 'version', newVersion )
183+
properties.setProperty( property, newVersion )
188184
properties.store( propertiesFile.newWriter(), null )
189185

190186
println "Bumped version from ${currentVersion} to ${newVersion}"

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
## [Unreleased]
1111

12+
### Fixed
13+
14+
- Detection on `boxlang file` execution with invalid paths was not working properly.
15+
1216
## [1.0.0] - 2025-04-30
1317

1418
[Unreleased]: https://github.com/ortus-boxlang/BoxLang/compare/v1.0.0...HEAD

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#Tue Feb 18 09:03:33 UTC 2025
22
antlrVersion=4.13.1
33
jdkVersion=21
4-
version=1.0.0
4+
version=1.0.1

src/main/java/ortus/boxlang/runtime/BoxRunner.java

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import java.util.stream.Collectors;
3232
import java.util.stream.Stream;
3333

34-
import org.apache.commons.io.FilenameUtils;
3534
import org.apache.commons.lang3.StringUtils;
3635

3736
import com.fasterxml.jackson.jr.ob.JSONObjectException;
@@ -470,9 +469,9 @@ private static CLIOptions parseCommandLineOptions( String[] args ) {
470469
}
471470

472471
// Template to execute?
473-
Path targetPath = getExecutableTemplate( currentArgument );
474-
if ( actionCommand == null && Files.exists( targetPath ) ) {
475-
file = targetPath.toString();
472+
String targetPath = getExecutableTemplate( currentArgument );
473+
if ( actionCommand == null && targetPath != null ) {
474+
file = targetPath;
476475
continue;
477476
}
478477

@@ -514,26 +513,45 @@ private static CLIOptions parseCommandLineOptions( String[] args ) {
514513
/**
515514
* Verifies if the passed in path is a valid template for execution
516515
*
517-
* @param path The path to the template
516+
* @param path Possible path to the template
518517
*
519-
* @return Whether or not the template is valid for execution
518+
* @return The absolute path if it's valid and exists, null otherwise
520519
*/
521-
private static Path getExecutableTemplate( String path ) {
522-
String extension = FilenameUtils.getExtension( path );
520+
private static String getExecutableTemplate( String path ) {
521+
String[] currentParts = path.split( "\\." );
522+
String currentExt = "";
523523

524+
if ( currentParts.length > 0 ) {
525+
currentExt = "." + currentParts[ currentParts.length - 1 ].toLowerCase();
526+
}
524527
// Do we have the extension? If not, let's assume it's a class
525-
if ( extension.isEmpty() ) {
526-
extension = "bx";
527-
path += ".bx";
528+
boolean presumptiveExtension = false;
529+
if ( currentExt.isEmpty() ) {
530+
currentExt = "bx";
531+
path += ".bx";
532+
presumptiveExtension = true;
528533
}
529534

530535
// Check if the extension is allowed or not
531-
if ( !ALLOWED_TEMPLATE_EXECUTIONS.contains( "." + extension ) ) {
532-
return Path.of( path );
536+
if ( !ALLOWED_TEMPLATE_EXECUTIONS.contains( currentExt ) ) {
537+
return null;
533538
}
534539

535540
// Check if the file exists
536-
return Path.of( templateToAbsolute( path ) );
541+
String absPath = templateToAbsolute( path );
542+
try {
543+
Path templatePath = Paths.get( absPath );
544+
545+
if ( !Files.exists( templatePath ) ) {
546+
if ( !presumptiveExtension ) {
547+
throw new BoxRuntimeException( "The template [" + path + "] does not exist." );
548+
}
549+
return null;
550+
}
551+
} catch ( InvalidPathException e ) {
552+
return null;
553+
}
554+
return absPath;
537555
}
538556

539557
/**

0 commit comments

Comments
 (0)