Skip to content

Commit 49ea2d0

Browse files
authored
Merge pull request #321 from tacincorporated/master
Support editable packages with Pipfile.
2 parents 0ed8021 + bc50d36 commit 49ea2d0

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

lib/pipenv.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const fse = require('fs-extra');
22
const path = require('path');
33
const { spawnSync } = require('child_process');
4+
const { EOL } = require('os');
45

56
/**
67
* pipenv install
@@ -36,8 +37,24 @@ function pipfileToRequirements() {
3637
fse.ensureDirSync(path.join(this.servicePath, '.serverless'));
3738
fse.writeFileSync(
3839
path.join(this.servicePath, '.serverless/requirements.txt'),
39-
res.stdout
40+
removeEditableFlagFromRequirementsString(res.stdout)
4041
);
4142
}
4243

44+
/**
45+
*
46+
* @param requirementBuffer
47+
* @returns Buffer with editable flags remove
48+
*/
49+
function removeEditableFlagFromRequirementsString(requirementBuffer) {
50+
const flagStr = '-e ';
51+
const lines = requirementBuffer.toString('utf8').split(EOL);
52+
for (let i = 0; i < lines.length; i++) {
53+
if (lines[i].startsWith(flagStr)) {
54+
lines[i] = lines[i].substring(flagStr.length);
55+
}
56+
}
57+
return Buffer.from(lines.join(EOL));
58+
}
59+
4360
module.exports = { pipfileToRequirements };

0 commit comments

Comments
 (0)