Skip to content

Remove sorting of requirements file #427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions lib/pip.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,32 +374,17 @@ function getRequirements(source) {
function filterRequirementsFile(source, target, options) {
const noDeploy = new Set(options.noDeploy || []);
const requirements = getRequirements(source);
var prepend = [];
const filteredRequirements = requirements.filter(req => {
req = req.trim();
if (req.startsWith('#')) {
// Skip comments
return false;
} else if (
req.startsWith('--') ||
req.startsWith('-f') ||
req.startsWith('-i')
) {
// If we have options (prefixed with --) keep them for later
prepend.push(req);
return false;
} else if (req === '') {
return false;
}
return !noDeploy.has(req.split(/[=<> \t]/)[0].trim());
});
filteredRequirements.sort(); // Sort remaining alphabetically
// Then prepend any options from above in the same order
for (let item of prepend.reverse()) {
if (item && item.length > 0) {
filteredRequirements.unshift(item);
}
}

fse.writeFileSync(target, filteredRequirements.join('\n') + '\n');
}

Expand Down