Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,33 +56,35 @@ class CmdModuleRun extends CmdRun {

@Override
void run() {
final moduleFile = resolveModuleSource()
if( moduleFile ) {
args[0] = moduleFile.toAbsolutePath().toString()
super.run()
}
}

protected Path resolveModuleSource() {
if( !args ) {
throw new AbortOperationException("Module name/path not provided")
}

final moduleFile = isLocalModule(args[0])
return isLocalModule(args[0])
? resolveLocalModule(args[0])
: resolveRemoteModule(args[0], version)

if( moduleFile ) {
args[0] = moduleFile.toAbsolutePath().toString()
super.run()
}
}

private boolean isLocalModule(String str) {
return str.startsWith('/') || str.startsWith('./') || str.startsWith('../')
}

private Path resolveLocalModule(String str) {
protected Path resolveLocalModule(String str) {
final module = Path.of(str).toAbsolutePath().normalize()
final path = module.isDirectory() ? module.resolve(Const.DEFAULT_MAIN_FILE_NAME) : module
if( !path.exists() )
throw new AbortOperationException("Invalid module path: ${str}")
return path
}

private Path resolveRemoteModule(String name, String version) {
protected Path resolveRemoteModule(String name, String version) {
// Parse and validate module reference
ModuleReference reference
try {
Expand Down
Loading
Loading