Skip to content

Commit

Permalink
fix: specify targetFile for pipenv projects
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Drukh authored and adrukh committed Aug 6, 2018
1 parent e567e3a commit 9647686
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function inspect(root, targetFile, options) {
}

return Promise.all([
getMetaData(command, baseargs, root),
getMetaData(command, baseargs, root, targetFile),
getDependencies(
command,
baseargs,
Expand All @@ -50,7 +50,7 @@ function inspect(root, targetFile, options) {
});
}

function getMetaData(command, baseargs, root) {
function getMetaData(command, baseargs, root, targetFile) {
return subProcess.execute(
command,
[].concat(baseargs, ['--version']),
Expand All @@ -60,6 +60,9 @@ function getMetaData(command, baseargs, root) {
return {
name: 'snyk-python-plugin',
runtime: output.replace('\n', ''),
// specify targetFile only in case of Pipfile
targetFile:
(path.basename(targetFile) === 'Pipfile') ? targetFile : undefined,
};
});
}
Expand Down
4 changes: 4 additions & 0 deletions test/inspect.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ test('inspect', function (t) {
t.ok(plugin, 'plugin');
t.equal(plugin.name, 'snyk-python-plugin', 'name');
t.match(plugin.runtime, 'Python', 'runtime');
t.notOk(plugin.targetFile, 'no targetfile for requirements.txt');
t.end();
});

Expand Down Expand Up @@ -468,8 +469,11 @@ test('inspect Pipfile', function (t) {
return plugin.inspect('.', 'Pipfile');
})
.then(function (result) {
var plugin = result.plugin;
var pkg = result.package;

t.equal(plugin.targetFile, 'Pipfile', 'Pipfile targetfile');

t.test('package dependencies', function (t) {
t.notOk(pkg.dependencies['django'], 'django skipped (editable)');

Expand Down

0 comments on commit 9647686

Please sign in to comment.