@@ -27,15 +27,19 @@ function quote_single(quoteme) {
27
27
* @param {Object } options
28
28
* @return {undefined }
29
29
*/
30
- function installRequirementsFile (
30
+ function generateRequirementsFile (
31
31
requirementsPath ,
32
32
targetFile ,
33
33
serverless ,
34
34
servicePath ,
35
35
options
36
36
) {
37
37
if ( options . usePipenv && fse . existsSync ( path . join ( servicePath , 'Pipfile' ) ) ) {
38
- generateRequirementsFile (
38
+ filterRequirementsFile (
39
+ /*
40
+ TODO: this is supposed to generate a requirements.txt from Pipfile,
41
+ but source and target are basicalle the same
42
+ */
39
43
path . join ( servicePath , '.serverless/requirements.txt' ) ,
40
44
targetFile ,
41
45
options
@@ -44,7 +48,7 @@ function installRequirementsFile(
44
48
`Parsed requirements.txt from Pipfile in ${ targetFile } ...`
45
49
) ;
46
50
} else {
47
- generateRequirementsFile ( requirementsPath , targetFile , options ) ;
51
+ filterRequirementsFile ( requirementsPath , targetFile , options ) ;
48
52
serverless . cli . log (
49
53
`Generated requirements from ${ requirementsPath } in ${ targetFile } ...`
50
54
) ;
@@ -300,7 +304,7 @@ function dockerPathForWin(options, path) {
300
304
* @param {string } target requirements where results are written
301
305
* @param {Object } options
302
306
*/
303
- function generateRequirementsFile ( source , target , options ) {
307
+ function filterRequirementsFile ( source , target , options ) {
304
308
const noDeploy = new Set ( options . noDeploy || [ ] ) ;
305
309
const requirements = fse
306
310
. readFileSync ( source , { encoding : 'utf-8' } )
@@ -381,11 +385,21 @@ function installRequirementsIfNeeded(
381
385
// Our source requirements, under our service path, and our module path (if specified)
382
386
const fileName = path . join ( servicePath , modulePath , options . fileName ) ;
383
387
384
- // First, generate the requirements file to our local .serverless folder
385
- fse . ensureDirSync ( path . join ( servicePath , '.serverless' ) ) ;
386
- const slsReqsTxt = path . join ( servicePath , '.serverless' , 'requirements.txt' ) ;
388
+ let requirementsTxtDirectory ;
389
+ // Copy our requirements to another filename in .serverless (incase of individually packaged)
390
+ if ( modulePath && modulePath != '.' ) {
391
+ requirementsTxtDirectory = path . join (
392
+ servicePath ,
393
+ '.serverless' ,
394
+ modulePath
395
+ ) ;
396
+ } else {
397
+ requirementsTxtDirectory = path . join ( servicePath , '.serverless' ) ;
398
+ }
399
+ fse . ensureDirSync ( requirementsTxtDirectory ) ;
400
+ const slsReqsTxt = path . join ( requirementsTxtDirectory , 'requirements.txt' ) ;
387
401
388
- installRequirementsFile (
402
+ generateRequirementsFile (
389
403
fileName ,
390
404
slsReqsTxt ,
391
405
serverless ,
@@ -401,28 +415,13 @@ function installRequirementsIfNeeded(
401
415
return false ;
402
416
}
403
417
404
- // Copy our requirements to another filename in .serverless (incase of individually packaged)
405
- if ( modulePath && modulePath != '.' ) {
406
- fse . existsSync ( path . join ( servicePath , '.serverless' , modulePath ) ) ;
407
- const destinationFile = path . join (
408
- servicePath ,
409
- '.serverless' ,
410
- modulePath ,
411
- 'requirements.txt'
412
- ) ;
413
- serverless . cli . log (
414
- `Copying from ${ slsReqsTxt } into ${ destinationFile } ...`
415
- ) ;
416
- fse . copySync ( slsReqsTxt , destinationFile ) ;
417
- }
418
-
419
418
// Then generate our MD5 Sum of this requirements file to determine where it should "go" to and/or pull cache from
420
419
const reqChecksum = md5Path ( slsReqsTxt ) ;
421
420
422
421
// Then figure out where this cache should be, if we're caching, if we're in a module, etc
423
422
const workingReqsFolder = getRequirementsWorkingPath (
424
423
reqChecksum ,
425
- servicePath ,
424
+ requirementsTxtDirectory ,
426
425
options
427
426
) ;
428
427
0 commit comments