Move claritas invocation to separate function, clean versions in Claritas.

This commit is contained in:
Daniel Scalzi
2020-07-15 18:59:56 -04:00
parent ea23912a85
commit 0ac31e5eb7
2 changed files with 32 additions and 27 deletions

Binary file not shown.

View File

@@ -126,6 +126,36 @@ export abstract class ModuleStructure extends BaseModelStructure<Module> {
} }
protected async invokeClaritas(moduleCandidates: ModuleCandidate[]): Promise<void> {
if(this.getClaritasType() != null) {
const claritasExecutor = new ClaritasWrapper()
let claritasCandidates = moduleCandidates
const exceptionCandidates: [ModuleCandidate, ClaritasException][] = []
for(const exception of this.getClaritasExceptions()) {
const exceptionCandidate = moduleCandidates.find((value) => value.file.toLowerCase().indexOf(exception.exceptionName) > -1)
if(exceptionCandidate != null) {
exceptionCandidates.push([exceptionCandidate, exception])
claritasCandidates = claritasCandidates.filter((value) => value.file.toLowerCase().indexOf(exception.exceptionName) === -1)
}
}
this.claritasResult = await claritasExecutor.execute(
this.getClaritasType()!,
this.minecraftVersion,
claritasCandidates.map(entry => entry.filePath)
)
if(this.claritasResult == null) {
this.logger.error('Failed to process Claritas result!')
} else {
for(const [candidate, exception] of exceptionCandidates) {
this.claritasResult[candidate.filePath] = exception.proxyMetadata
}
}
}
}
protected async _doModuleRetrieval(moduleCandidates: ModuleCandidate[], options?: { protected async _doModuleRetrieval(moduleCandidates: ModuleCandidate[], options?: {
preProcess?: (candidate: ModuleCandidate) => void preProcess?: (candidate: ModuleCandidate) => void
postProcess?: (module: Module) => void postProcess?: (module: Module) => void
@@ -135,33 +165,8 @@ export abstract class ModuleStructure extends BaseModelStructure<Module> {
if(moduleCandidates.length > 0) { if(moduleCandidates.length > 0) {
// Invoke Claritas // Invoke Claritas and attach result to class.
if(this.getClaritasType() != null) { await this.invokeClaritas(moduleCandidates)
const claritasExecutor = new ClaritasWrapper()
let claritasCandidates = moduleCandidates
const exceptionCandidates: [ModuleCandidate, ClaritasException][] = []
for(const exception of this.getClaritasExceptions()) {
const exceptionCandidate = moduleCandidates.find((value) => value.file.toLowerCase().indexOf(exception.exceptionName) > -1)
if(exceptionCandidate != null) {
exceptionCandidates.push([exceptionCandidate, exception])
claritasCandidates = claritasCandidates.filter((value) => value.file.toLowerCase().indexOf(exception.exceptionName) === -1)
}
}
this.claritasResult = await claritasExecutor.execute(
this.getClaritasType()!,
this.minecraftVersion,
claritasCandidates.map(entry => entry.filePath)
)
if(this.claritasResult == null) {
this.logger.error('Failed to process Claritas result!')
} else {
for(const [candidate, exception] of exceptionCandidates) {
this.claritasResult[candidate.filePath] = exception.proxyMetadata
}
}
}
// Process Modules // Process Modules
for(const candidate of moduleCandidates) { for(const candidate of moduleCandidates) {