* Reads the projects pom.xml file * * @returns {Promise } Resolves with a JSON representation of the content
()
| 350 | * @returns {Promise<object>} Resolves with a JSON representation of the content |
| 351 | */ |
| 352 | async _getPom() { |
| 353 | if (this._pPom) { |
| 354 | return this._pPom; |
| 355 | } |
| 356 | |
| 357 | return this._pPom = this.getRootReader().byPath("/pom.xml") |
| 358 | .then(async (resource) => { |
| 359 | if (!resource) { |
| 360 | throw new Error( |
| 361 | `Could not find pom.xml in project ${this.getName()}`); |
| 362 | } |
| 363 | const content = await resource.getString(); |
| 364 | const { |
| 365 | default: xml2js |
| 366 | } = await import("xml2js"); |
| 367 | const parser = new xml2js.Parser({ |
| 368 | explicitArray: false, |
| 369 | ignoreAttrs: true |
| 370 | }); |
| 371 | const readXML = promisify(parser.parseString); |
| 372 | return readXML(content); |
| 373 | }).catch((err) => { |
| 374 | throw new Error( |
| 375 | `Failed to read pom.xml for project ${this.getName()}: ${err.message}`); |
| 376 | }); |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | export default ComponentProject; |
no test coverage detected