Skip to content

Commit

Permalink
Merge pull request #15 from snyk/feat/drop-group-id-and-artifact-id
Browse files Browse the repository at this point in the history
BREAKING CHANGE: drop unused groupId and artifactId attributes from response
  • Loading branch information
darscan authored Sep 25, 2018
2 parents d88bb07 + 5356121 commit c730af2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 428 deletions.
17 changes: 7 additions & 10 deletions lib/gradle-dep-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ module.exports = {
parse: parse,
};

function parse(text, from) {
function parse(text) {
var data = processGradleOutput(text);
var depArray = createTree(
data.lines, data.omittedDeps, {from: [from]});
var depArray = createTree(data.lines, data.omittedDeps);
fillOmittedDependencies(depArray, data.omittedDeps);
var depTree = convertNodeArrayToObject(depArray);
return depTree;
Expand Down Expand Up @@ -86,8 +85,6 @@ function getElementAsObject(element) {
var artifactId = elementParts[1];
var version = elementParts[2];
return {
groupId: groupId,
artifactId: artifactId,
version: version,
name: groupId + ':' + artifactId,
// array is required to keep the order for omitted deps,
Expand Down Expand Up @@ -119,14 +116,14 @@ function cloneDependencies(node, omittedDeps) {
return clonedDeps;
}

function createTree(lines, omittedDeps, parentElement) {
function createTree(lines, omittedDeps) {
if (lines.length === 0) {
return [];
}
var array = [];
var currentLine = lines.shift();
var currentIndent = getIndent(currentLine);
var current = getElementAsObject(currentLine, parentElement);
var current = getElementAsObject(currentLine);
array.push(current);

var nextLine = lines[0];
Expand All @@ -135,14 +132,14 @@ function createTree(lines, omittedDeps, parentElement) {
while (nextLine) {
nextIndent = getIndent(nextLine);
if (nextIndent === currentIndent) {
next = getElementAsObject(lines[0], parentElement);
next = getElementAsObject(lines[0]);
array.push(next);
lines.shift();
} else if (nextIndent > currentIndent) {
next = getElementAsObject(lines[0], current);
next = getElementAsObject(lines[0]);
var subTreeLines = getSubTreeLines(lines, currentIndent);
lines.splice(0, subTreeLines.length);
current.dependencies = createTree(subTreeLines, omittedDeps, current);
current.dependencies = createTree(subTreeLines, omittedDeps);
}
if (omittedDeps[current.name] === true) {
// we have an omitted dependency somewhere
Expand Down
Loading

0 comments on commit c730af2

Please sign in to comment.