@@ -50,25 +50,15 @@ function injectRequirements(requirementsPath, packagePath, options) {
50
50
* @param {string } module module to keep
51
51
* @return {Promise } the JSZip object written out.
52
52
*/
53
- function injectSourceCode ( source , target , module , options ) {
53
+ function injectSourceCode ( source , target , module ) {
54
54
const targetZip = new JSZip ( ) ;
55
55
56
56
return fse
57
57
. readFileAsync ( source )
58
58
. then ( buffer => JSZip . loadAsync ( buffer ) )
59
59
. then ( sourceZip => sourceZip . filter ( ( ) => true ) )
60
60
. map ( srcZipObj => {
61
- let targetName ;
62
-
63
- if (
64
- options . IndividuallyMoveUpModules === true ||
65
- options . IndividuallyMoveUpModules == 'true'
66
- ) {
67
- targetName = srcZipObj . name . replace ( module + '/' , '' ) ;
68
- } else {
69
- targetName = srcZipObj . name ;
70
- }
71
-
61
+ let targetName = srcZipObj . name . replace ( module + '/' , '' ) ;
72
62
return zipFile ( targetZip , targetName , srcZipObj . async ( 'nodebuffer' ) ) ;
73
63
} )
74
64
. then ( ( ) => writeZip ( targetZip , target ) ) ;
@@ -95,19 +85,19 @@ function injectAllRequirements(funcArtifact) {
95
85
return func ;
96
86
} )
97
87
. map ( func => {
98
- if ( func . module !== '.' ) {
88
+ if (
89
+ this . options . IndividuallyMoveUpModules === true ||
90
+ this . options . IndividuallyMoveUpModules === 'true'
91
+ ) {
99
92
const artifact = func . package ? func . package . artifact : funcArtifact ;
100
93
const newArtifact = path . join (
101
94
'.serverless' ,
102
95
`${ func . module } -${ func . name } .zip`
103
96
) ;
104
97
func . package . artifact = newArtifact ;
105
- return injectSourceCode (
106
- artifact ,
107
- newArtifact ,
108
- func . module ,
109
- this . options
110
- ) . then ( ( ) => func ) ;
98
+ return injectSourceCode ( artifact , newArtifact , func . module ) . then (
99
+ ( ) => func
100
+ ) ;
111
101
} else {
112
102
return func ;
113
103
}
@@ -116,10 +106,10 @@ function injectAllRequirements(funcArtifact) {
116
106
return this . options . zip
117
107
? func
118
108
: injectRequirements (
119
- path . join ( '.serverless' , func . module , 'requirements' ) ,
120
- func . package . artifact ,
121
- this . options
122
- ) ;
109
+ path . join ( '.serverless' , func . module , 'requirements' ) ,
110
+ func . package . artifact ,
111
+ this . options
112
+ ) ;
123
113
} ) ;
124
114
} else if ( ! this . options . zip ) {
125
115
return injectRequirements (
0 commit comments