Use TypeMetadata for lib extension, listen to process error event.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { ModuleStructure } from './module.struct'
|
||||
import { Type } from 'helios-distribution-types'
|
||||
import { Type, TypeMetadata } from 'helios-distribution-types'
|
||||
import { Stats } from 'fs-extra'
|
||||
import { join } from 'path'
|
||||
import { resolve } from 'url'
|
||||
@@ -7,7 +7,6 @@ import { resolve } from 'url'
|
||||
export class LibraryStructure extends ModuleStructure {
|
||||
|
||||
private readonly crudeRegex = /(.+)-([\d.]+).[jJ][aA][rR]/
|
||||
private readonly libraryExt = '.jar'
|
||||
|
||||
constructor(
|
||||
absoluteRoot: string,
|
||||
@@ -15,7 +14,7 @@ export class LibraryStructure extends ModuleStructure {
|
||||
baseUrl: string
|
||||
) {
|
||||
super(absoluteRoot, relativeRoot, 'libraries', baseUrl, Type.Library, (name: string) => {
|
||||
return name.toLowerCase().endsWith(this.libraryExt)
|
||||
return name.toLowerCase().endsWith(TypeMetadata[this.type].defaultExtension!)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -28,7 +27,7 @@ export class LibraryStructure extends ModuleStructure {
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
name: name.substring(0, name.toLowerCase().indexOf(this.libraryExt)),
|
||||
name: name.substring(0, name.toLowerCase().indexOf(TypeMetadata[this.type].defaultExtension!)),
|
||||
version: '0.0.0'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ export class PackXZExtractWrapper {
|
||||
}
|
||||
|
||||
private static execute(command: string, paths: string[]): Promise<void> {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const child = spawn(JavaUtil.getJavaExecutable(), [
|
||||
'-jar',
|
||||
PackXZExtractWrapper.getPackXZExtract(),
|
||||
@@ -34,6 +34,10 @@ export class PackXZExtractWrapper {
|
||||
console.log('[PackXZExtract]', 'Exited with code', code)
|
||||
resolve()
|
||||
})
|
||||
child.on('error', (err) => {
|
||||
console.log('[PackXZExtract]', 'Error during process execution', err)
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user