Skip to content

Commit

Permalink
feat: support setup.py as a return target file
Browse files Browse the repository at this point in the history
  • Loading branch information
dkontorovskyy committed Dec 1, 2019
1 parent 2446247 commit 90a4140
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions lib/inspect-implementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ export function getMetaData(
return {
name: 'snyk-python-plugin',
runtime: output.replace('\n', ''),
// specify targetFile only in case of Pipfile
targetFile:
path.basename(targetFile) === 'Pipfile' ? targetFile : undefined,
// specify targetFile only in case of Pipfile or setup.py
targetFile: path.basename(targetFile).match(/^(Pipfile|setup\.py)$/)
? targetFile
: undefined,
};
});
}
Expand Down
2 changes: 1 addition & 1 deletion test/inspect-provenance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ test('inspect setup.py', async (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 setup.py');
t.equal(plugin.targetFile, 'setup.py', 'targetfile is setup.py');
});

t.test('package', async (t) => {
Expand Down
2 changes: 1 addition & 1 deletion test/inspect.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ test('inspect setup.py', (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 setup.py');
t.equal(plugin.targetFile, 'setup.py', 'targetfile is setup.py');
t.end();
});

Expand Down

0 comments on commit 90a4140

Please sign in to comment.