Skip to content

Adding -f and -i to requirements.txt options ignore list before sorting #238

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

Merged
merged 4 commits into from
Sep 14, 2018
Merged
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
14 changes: 11 additions & 3 deletions lib/pip.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,9 @@ function dockerPathForWin(options, path) {
* then remove all comments and empty lines, and sort the list which
* assist with matching the static cache. The sorting will skip any
* lines starting with -- as those are typically ordered at the
* start of a file ( eg: --index-url / --extra-index-url )
* start of a file ( eg: --index-url / --extra-index-url ) or any
* lines that start with -f or -i, Please see:
* https://pip.pypa.io/en/stable/reference/pip_install/#requirements-file-format
* @param {string} source requirements
* @param {string} target requirements where results are written
* @param {Object} options
Expand All @@ -297,7 +299,11 @@ function generateRequirementsFile(source, target, options) {
if (req.startsWith('#')) {
// Skip comments
return false;
} else if (req.startsWith('--')) {
} 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;
Expand All @@ -309,7 +315,9 @@ function generateRequirementsFile(source, target, options) {
filteredRequirements.sort(); // Sort remaining alphabetically
// Then prepend any options from above in the same order
for (let item of prepend.reverse()) {
filteredRequirements.unshift(item);
if (item && item.length > 0) {
filteredRequirements.unshift(item);
}
}
fse.writeFileSync(target, filteredRequirements.join('\n') + '\n');
}
Expand Down