@@ -53,15 +53,19 @@ function mergeCommands(commands) {
53
53
* @param {Object } options
54
54
* @return {undefined }
55
55
*/
56
- function installRequirementsFile (
56
+ function generateRequirementsFile (
57
57
requirementsPath ,
58
58
targetFile ,
59
59
serverless ,
60
60
servicePath ,
61
61
options
62
62
) {
63
63
if ( options . usePipenv && fse . existsSync ( path . join ( servicePath , 'Pipfile' ) ) ) {
64
- generateRequirementsFile (
64
+ filterRequirementsFile (
65
+ /*
66
+ TODO: this is supposed to generate a requirements.txt from Pipfile,
67
+ but source and target are basicalle the same
68
+ */
65
69
path . join ( servicePath , '.serverless/requirements.txt' ) ,
66
70
targetFile ,
67
71
options
@@ -70,7 +74,7 @@ function installRequirementsFile(
70
74
`Parsed requirements.txt from Pipfile in ${ targetFile } ...`
71
75
) ;
72
76
} else {
73
- generateRequirementsFile ( requirementsPath , targetFile , options ) ;
77
+ filterRequirementsFile ( requirementsPath , targetFile , options ) ;
74
78
serverless . cli . log (
75
79
`Generated requirements from ${ requirementsPath } in ${ targetFile } ...`
76
80
) ;
@@ -306,7 +310,6 @@ function dockerPathForWin(path) {
306
310
return path ;
307
311
}
308
312
}
309
-
310
313
/** create a filtered requirements.txt without anything from noDeploy
311
314
* then remove all comments and empty lines, and sort the list which
312
315
* assist with matching the static cache. The sorting will skip any
@@ -318,7 +321,7 @@ function dockerPathForWin(path) {
318
321
* @param {string } target requirements where results are written
319
322
* @param {Object } options
320
323
*/
321
- function generateRequirementsFile ( source , target , options ) {
324
+ function filterRequirementsFile ( source , target , options ) {
322
325
const noDeploy = new Set ( options . noDeploy || [ ] ) ;
323
326
const requirements = fse
324
327
. readFileSync ( source , { encoding : 'utf-8' } )
@@ -413,11 +416,21 @@ function installRequirementsIfNeeded(
413
416
}
414
417
}
415
418
416
- // First, generate the requirements file to our local .serverless folder
417
- fse . ensureDirSync ( path . join ( servicePath , '.serverless' ) ) ;
418
- const slsReqsTxt = path . join ( servicePath , '.serverless' , 'requirements.txt' ) ;
419
+ let requirementsTxtDirectory ;
420
+ // Copy our requirements to another path in .serverless (incase of individually packaged)
421
+ if ( modulePath && modulePath != '.' ) {
422
+ requirementsTxtDirectory = path . join (
423
+ servicePath ,
424
+ '.serverless' ,
425
+ modulePath
426
+ ) ;
427
+ } else {
428
+ requirementsTxtDirectory = path . join ( servicePath , '.serverless' ) ;
429
+ }
430
+ fse . ensureDirSync ( requirementsTxtDirectory ) ;
431
+ const slsReqsTxt = path . join ( requirementsTxtDirectory , 'requirements.txt' ) ;
419
432
420
- installRequirementsFile (
433
+ generateRequirementsFile (
421
434
fileName ,
422
435
slsReqsTxt ,
423
436
serverless ,
@@ -433,28 +446,13 @@ function installRequirementsIfNeeded(
433
446
return false ;
434
447
}
435
448
436
- // Copy our requirements to another filename in .serverless (incase of individually packaged)
437
- if ( modulePath && modulePath != '.' ) {
438
- fse . existsSync ( path . join ( servicePath , '.serverless' , modulePath ) ) ;
439
- const destinationFile = path . join (
440
- servicePath ,
441
- '.serverless' ,
442
- modulePath ,
443
- 'requirements.txt'
444
- ) ;
445
- serverless . cli . log (
446
- `Copying from ${ slsReqsTxt } into ${ destinationFile } ...`
447
- ) ;
448
- fse . copySync ( slsReqsTxt , destinationFile ) ;
449
- }
450
-
451
449
// Then generate our MD5 Sum of this requirements file to determine where it should "go" to and/or pull cache from
452
450
const reqChecksum = md5Path ( slsReqsTxt ) ;
453
451
454
452
// Then figure out where this cache should be, if we're caching, if we're in a module, etc
455
453
const workingReqsFolder = getRequirementsWorkingPath (
456
454
reqChecksum ,
457
- servicePath ,
455
+ requirementsTxtDirectory ,
458
456
options
459
457
) ;
460
458
0 commit comments