Skip to content

Commit 66ca77a

Browse files
committedMar 29, 2021
feat: do not skip files with -r directive
1 parent bc44f9a commit 66ca77a

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed
 

‎packages/snyk-fix/src/plugins/python/handlers/pip-requirements/is-supported.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,13 @@ export async function isSupported(
4545
};
4646
}
4747

48-
const { containsRequire } = await containsRequireDirective(requirementsTxt);
49-
if (containsRequire) {
48+
const { containsRequire, matches } = await containsRequireDirective(
49+
requirementsTxt,
50+
);
51+
if (containsRequire && matches.some((m) => m.includes('c'))) {
5052
return {
5153
supported: false,
52-
reason: `Requirements with ${chalk.bold('-r')} or ${chalk.bold(
54+
reason: `Requirements with ${chalk.bold(
5355
'-c',
5456
)} directive are not yet supported`,
5557
};

‎packages/snyk-fix/test/acceptance/plugins/python/update-dependencies/update-dependencies.spec.ts

+14-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ describe('fix *req*.txt / *.txt Python projects', () => {
1212
filesToDelete.map((f) => fs.unlinkSync(f));
1313
});
1414
const workspacesPath = pathLib.resolve(__dirname, 'workspaces');
15-
it('skips projects with a -r option', async () => {
15+
16+
it('fixes project with a -r option', async () => {
1617
// Arrange
1718
const targetFile = 'with-require/dev.txt';
1819

@@ -72,15 +73,22 @@ describe('fix *req*.txt / *.txt Python projects', () => {
7273
results: {
7374
python: {
7475
failed: [],
75-
skipped: [
76+
skipped: [],
77+
succeeded: [
7678
{
7779
original: entityToFix,
78-
userMessage: expect.stringContaining(
79-
'directive are not yet supported',
80-
),
80+
changes: [
81+
{
82+
success: true,
83+
userMessage: 'Pinned transitive from 1.0.0 to 1.1.1',
84+
},
85+
{
86+
success: true,
87+
userMessage: 'Upgraded Django from 1.6.1 to 2.0.1',
88+
},
89+
],
8190
},
8291
],
83-
succeeded: [],
8492
},
8593
},
8694
});

‎packages/snyk-fix/test/unit/plugins/python/is-supported.ts ‎packages/snyk-fix/test/unit/plugins/python/is-supported.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ describe('isSupported', () => {
1313
const res = await isSupported(entity);
1414
expect(res.supported).toBeFalsy();
1515
});
16-
it('with -r directive in the manifest not supported', async () => {
16+
it('with -r directive in the manifest is supported', async () => {
1717
const entity = generateEntityToFix(
1818
'pip',
1919
'requirements.txt',
2020
'-r prod.txt\nDjango==1.6.1',
2121
);
2222
const res = await isSupported(entity);
23-
expect(res.supported).toBeFalsy();
23+
expect(res.supported).toBeTruthy();
2424
});
2525
it('with -c directive in the manifest not supported', async () => {
2626
const entity = generateEntityToFix(

0 commit comments

Comments
 (0)
Please sign in to comment.