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 { ModuleStructure } from './module.struct'
|
||||||
import { Type } from 'helios-distribution-types'
|
import { Type, TypeMetadata } from 'helios-distribution-types'
|
||||||
import { Stats } from 'fs-extra'
|
import { Stats } from 'fs-extra'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { resolve } from 'url'
|
import { resolve } from 'url'
|
||||||
@@ -7,7 +7,6 @@ import { resolve } from 'url'
|
|||||||
export class LibraryStructure extends ModuleStructure {
|
export class LibraryStructure extends ModuleStructure {
|
||||||
|
|
||||||
private readonly crudeRegex = /(.+)-([\d.]+).[jJ][aA][rR]/
|
private readonly crudeRegex = /(.+)-([\d.]+).[jJ][aA][rR]/
|
||||||
private readonly libraryExt = '.jar'
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
absoluteRoot: string,
|
absoluteRoot: string,
|
||||||
@@ -15,7 +14,7 @@ export class LibraryStructure extends ModuleStructure {
|
|||||||
baseUrl: string
|
baseUrl: string
|
||||||
) {
|
) {
|
||||||
super(absoluteRoot, relativeRoot, 'libraries', baseUrl, Type.Library, (name: 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 {
|
} else {
|
||||||
return {
|
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'
|
version: '0.0.0'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export class PackXZExtractWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static execute(command: string, paths: string[]): Promise<void> {
|
private static execute(command: string, paths: string[]): Promise<void> {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
const child = spawn(JavaUtil.getJavaExecutable(), [
|
const child = spawn(JavaUtil.getJavaExecutable(), [
|
||||||
'-jar',
|
'-jar',
|
||||||
PackXZExtractWrapper.getPackXZExtract(),
|
PackXZExtractWrapper.getPackXZExtract(),
|
||||||
@@ -34,6 +34,10 @@ export class PackXZExtractWrapper {
|
|||||||
console.log('[PackXZExtract]', 'Exited with code', code)
|
console.log('[PackXZExtract]', 'Exited with code', code)
|
||||||
resolve()
|
resolve()
|
||||||
})
|
})
|
||||||
|
child.on('error', (err) => {
|
||||||
|
console.log('[PackXZExtract]', 'Error during process execution', err)
|
||||||
|
reject(err)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user