Skip to content

Commit

Permalink
Merge pull request #51 from snyk/fix/handle_empty_projects
Browse files Browse the repository at this point in the history
fix: make sure that the projects const is iteratable
  • Loading branch information
odinn1984 committed Apr 15, 2019
2 parents b8857e5 + 4cd2bc2 commit 4808252
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/nuget-parser/packages-config-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ function parsePackagesConfigFileContents(fileContent) {
if (err) {
throw err;
} else {
result.packages.package.forEach(
const packages = result.packages.package || [];

packages.forEach(
function scanPackagesConfigNode(node) {
const installedDependency =
Dependency.from.packgesConfigEntry(node);
Expand Down
21 changes: 21 additions & 0 deletions test/parse-packages-config-no-deps.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

const test = require('tap').test;
const plugin = require('../lib/index');
const projectPath = './test/stubs/packages-config-no-deps/';

test('parse packages-config-no-deps project successfully', function (t) {
plugin.inspect(
projectPath,
'packages.config',
{
packagesFolder: projectPath + './_packages',
})
.then(function () {
t.pass('parsed file correctly');
t.end();
})
.catch(function () {
t.fail('failed parsing a project with no deps');
});
});
5 changes: 5 additions & 0 deletions test/stubs/packages-config-no-deps/nodeps.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
</Project>
3 changes: 3 additions & 0 deletions test/stubs/packages-config-no-deps/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
</packages>

0 comments on commit 4808252

Please sign in to comment.