File: /home/frenchy/www/french-american.org/current/node_modules/snyk-mvn-plugin/dist/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const parse_mvn_1 = require("./parse-mvn");
const fs = require("fs");
const path = require("path");
const subProcess = require("./sub-process");
function inspect(root, targetFile, options) {
if (!options) {
options = { dev: false };
}
const mvnArgs = buildArgs(root, targetFile, options.args);
return subProcess.execute('mvn', mvnArgs, { cwd: root })
.then((result) => {
const parseResult = parse_mvn_1.parseTree(result, options.dev);
return {
plugin: {
name: 'bundled:maven',
runtime: 'unknown',
},
package: parseResult.data,
};
})
.catch((error) => {
error.message = error.message + '\n\n' +
'Please make sure that Apache Maven Dependency Plugin ' +
'version 2.2 or above is installed, and that ' +
'`mvn ' + mvnArgs.join(' ') + '` executes successfully ' +
'on this project.\n\n' +
'If the problem persists, collect the output of ' +
'`mvn ' + mvnArgs.join(' ') + '` and contact support@snyk.io\n';
throw error;
});
}
exports.inspect = inspect;
function buildArgs(root, targetFile, mavenArgs) {
// Requires Maven >= 2.2
let args = ['dependency:tree', '-DoutputType=dot'];
if (targetFile) {
if (!fs.existsSync(path.resolve(root, targetFile))) {
throw new Error('File not found: "' + targetFile + '"');
}
args.push('--file="' + targetFile + '"');
}
if (mavenArgs) {
args = args.concat(mavenArgs);
}
return args;
}
exports.buildArgs = buildArgs;
//# sourceMappingURL=index.js.map