Skip to content

Commit

Permalink
Merge pull request #2035 from snyk/feat/release-command-support
Browse files Browse the repository at this point in the history
feat: support --command for Poetry fix
  • Loading branch information
lili2311 authored Jun 16, 2021
2 parents e3cae5f + 0210956 commit eb226ae
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/snyk-fix/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"dependencies": {
"@snyk/dep-graph": "^1.21.0",
"@snyk/fix-pipenv-pipfile": "0.5.3",
"@snyk/fix-poetry": "0.6.0",
"@snyk/fix-poetry": "0.7.0",
"chalk": "4.1.1",
"debug": "^4.3.1",
"lodash.groupby": "4.6.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ export async function updateDependencies(

// update prod dependencies first
if (!options.dryRun && upgrades.length) {
const res = await poetryFix.poetryAdd(dir, upgrades, {});
const res = await poetryFix.poetryAdd(dir, upgrades, {
python: entity.options.command ?? undefined,
});
if (res.exitCode !== 0) {
poetryCommand = res.command;
throwPoetryError(res.stderr ? res.stderr : res.stdout, res.command);
Expand All @@ -63,6 +65,7 @@ export async function updateDependencies(
if (!options.dryRun && devUpgrades.length) {
const res = await poetryFix.poetryAdd(dir, devUpgrades, {
dev: true,
python: entity.options.command ?? undefined,
});
if (res.exitCode !== 0) {
poetryCommand = res.command;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ describe('fix Poetry Python projects', () => {
expect(poetryFixStub.mock.calls[0]).toEqual([
pathLib.resolve(workspacesPath, 'simple'),
['six==2.0.1', 'transitive==1.1.1'],
{},
{
python: 'python3',
},
]);
});

Expand Down Expand Up @@ -276,7 +278,7 @@ describe('fix Poetry Python projects', () => {
},
]);
});
it('pins a transitive dep', async () => {
it('pins a transitive dep with custom python interpreter via --command', async () => {
jest.spyOn(poetryFix, 'poetryAdd').mockResolvedValue({
exitCode: 0,
stdout: '',
Expand Down Expand Up @@ -308,7 +310,9 @@ describe('fix Poetry Python projects', () => {
workspacesPath,
targetFile,
testResult,
{},
{
command: 'python2',
},
);

// Act
Expand Down Expand Up @@ -341,10 +345,11 @@ describe('fix Poetry Python projects', () => {
expect(poetryFixStub.mock.calls[0]).toEqual([
pathLib.resolve(workspacesPath, 'simple'),
['markupsafe==2.1.0'],
{},
{
python: 'python2',
},
]);
});
it.todo('--command support');
it('shows expected changes when updating a dev dep', async () => {
jest.spyOn(poetryFix, 'poetryAdd').mockResolvedValue({
exitCode: 0,
Expand Down

0 comments on commit eb226ae

Please sign in to comment.