|
4 | 4 | * ------------------------------------------------------------------------------------------ */ |
5 | 5 | 'use strict'; |
6 | 6 |
|
7 | | -import { execSync } from 'child_process'; |
| 7 | +import exhort from '@trustification/exhort-javascript-api'; |
8 | 8 |
|
9 | 9 | import { connection } from '../server'; |
10 | 10 | import { globalConfig } from '../config'; |
@@ -219,36 +219,13 @@ interface IOptions { |
219 | 219 | * @param options - The options for running image analysis. |
220 | 220 | * @returns A Promise resolving to the analysis response. |
221 | 221 | */ |
222 | | -function imageAnalysisService(images: IImage[], options: IOptions): Promise<any> { |
223 | | - return new Promise<any>((resolve, reject) => { |
224 | | - const jarPath = `${__dirname}/../javaApiAdapter/exhort-java-api-adapter-1.0-SNAPSHOT-jar-with-dependencies.jar`; |
225 | | - const reportType = 'json'; |
226 | | - let parameters = ''; |
227 | | - let properties = ''; |
228 | | - |
229 | | - images.forEach(image => { |
230 | | - if (image.platform) { |
231 | | - parameters += ` ${image.name.value}^^${image.platform}`; |
232 | | - } else { |
233 | | - parameters += ` ${image.name.value}`; |
234 | | - } |
235 | | - }); |
236 | | - |
237 | | - for (const setting in options) { |
238 | | - if (options[setting]) { |
239 | | - properties += ` -D${setting}=${options[setting]}`; |
240 | | - } |
| 222 | +async function imageAnalysisService(images: IImage[], options: IOptions): Promise<any> { |
| 223 | + return await exhort.imageAnalysis(images.map(img => { |
| 224 | + if (img.platform) { |
| 225 | + return `${img.name.value}^^${img.platform}`; |
241 | 226 | } |
242 | | - |
243 | | - try { |
244 | | - const result = execSync(`java${properties} -jar ${jarPath} ${reportType}${parameters}`, { |
245 | | - maxBuffer: 1000 * 1000 * 10, // 10 MB |
246 | | - }); |
247 | | - resolve(JSON.parse(result.toString())); |
248 | | - } catch (error) { |
249 | | - reject(error); |
250 | | - } |
251 | | - }); |
| 227 | + return img.name.value; |
| 228 | + }), true, options); |
252 | 229 | } |
253 | 230 |
|
254 | 231 | /** |
|
0 commit comments