Skip to content

Commit

Permalink
feat: do not skip files with -r directive
Browse files Browse the repository at this point in the history
  • Loading branch information
lili2311 committed Mar 29, 2021
1 parent bc44f9a commit 66ca77a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
Expand Up @@ -45,11 +45,13 @@ export async function isSupported(
};
}

const { containsRequire } = await containsRequireDirective(requirementsTxt);
if (containsRequire) {
const { containsRequire, matches } = await containsRequireDirective(
requirementsTxt,
);
if (containsRequire && matches.some((m) => m.includes('c'))) {
return {
supported: false,
reason: `Requirements with ${chalk.bold('-r')} or ${chalk.bold(
reason: `Requirements with ${chalk.bold(
'-c',
)} directive are not yet supported`,
};
Expand Down
Expand Up @@ -12,7 +12,8 @@ describe('fix *req*.txt / *.txt Python projects', () => {
filesToDelete.map((f) => fs.unlinkSync(f));
});
const workspacesPath = pathLib.resolve(__dirname, 'workspaces');
it('skips projects with a -r option', async () => {

it('fixes project with a -r option', async () => {
// Arrange
const targetFile = 'with-require/dev.txt';

Expand Down Expand Up @@ -72,15 +73,22 @@ describe('fix *req*.txt / *.txt Python projects', () => {
results: {
python: {
failed: [],
skipped: [
skipped: [],
succeeded: [
{
original: entityToFix,
userMessage: expect.stringContaining(
'directive are not yet supported',
),
changes: [
{
success: true,
userMessage: 'Pinned transitive from 1.0.0 to 1.1.1',
},
{
success: true,
userMessage: 'Upgraded Django from 1.6.1 to 2.0.1',
},
],
},
],
succeeded: [],
},
},
});
Expand Down
Expand Up @@ -13,14 +13,14 @@ describe('isSupported', () => {
const res = await isSupported(entity);
expect(res.supported).toBeFalsy();
});
it('with -r directive in the manifest not supported', async () => {
it('with -r directive in the manifest is supported', async () => {
const entity = generateEntityToFix(
'pip',
'requirements.txt',
'-r prod.txt\nDjango==1.6.1',
);
const res = await isSupported(entity);
expect(res.supported).toBeFalsy();
expect(res.supported).toBeTruthy();
});
it('with -c directive in the manifest not supported', async () => {
const entity = generateEntityToFix(
Expand Down

0 comments on commit 66ca77a

Please sign in to comment.