From 7d554716779c79dbffc6bac7cf40a28863115f4a Mon Sep 17 00:00:00 2001 From: Farley Date: Thu, 13 Sep 2018 19:02:50 +0200 Subject: [PATCH] Adding other requirements.txt header/index files to ignore list --- lib/pip.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/pip.js b/lib/pip.js index 3f13ee4e..c0151f00 100644 --- a/lib/pip.js +++ b/lib/pip.js @@ -269,7 +269,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 @@ -285,7 +287,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; @@ -295,7 +301,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')); }