@@ -14,29 +14,48 @@ async function pipfileToRequirements() {
14
14
return ;
15
15
}
16
16
17
- this . serverless . cli . log ( 'Generating requirements.txt from Pipfile...' ) ;
17
+ let generateRequirementsProgress ;
18
+ if ( this . progress ) {
19
+ generateRequirementsProgress = this . progress . get (
20
+ 'python-generate-requirements-pipfile'
21
+ ) ;
22
+ generateRequirementsProgress . update (
23
+ 'Generating requirements.txt from Pipfile' ,
24
+ { isMainEvent : true }
25
+ ) ;
26
+ } else {
27
+ this . serverless . cli . log ( 'Generating requirements.txt from Pipfile...' ) ;
28
+ }
18
29
19
- let res ;
20
30
try {
21
- res = await spawn ( 'pipenv' , [ 'lock' , '--requirements' , '--keep-outdated' ] , {
22
- cwd : this . servicePath ,
23
- } ) ;
24
- } catch ( e ) {
25
- if (
26
- e . stderrBuffer &&
27
- e . stderrBuffer . toString ( ) . includes ( 'command not found' )
28
- ) {
29
- throw new Error (
30
- `pipenv not found! Install it with 'pip install pipenv'.`
31
+ let res ;
32
+ try {
33
+ res = await spawn (
34
+ 'pipenv' ,
35
+ [ 'lock' , '--requirements' , '--keep-outdated' ] ,
36
+ {
37
+ cwd : this . servicePath ,
38
+ }
31
39
) ;
40
+ } catch ( e ) {
41
+ if (
42
+ e . stderrBuffer &&
43
+ e . stderrBuffer . toString ( ) . includes ( 'command not found' )
44
+ ) {
45
+ throw new Error (
46
+ `pipenv not found! Install it with 'pip install pipenv'.`
47
+ ) ;
48
+ }
49
+ throw e ;
32
50
}
33
- throw e ;
51
+ fse . ensureDirSync ( path . join ( this . servicePath , '.serverless' ) ) ;
52
+ fse . writeFileSync (
53
+ path . join ( this . servicePath , '.serverless/requirements.txt' ) ,
54
+ removeEditableFlagFromRequirementsString ( res . stdoutBuffer )
55
+ ) ;
56
+ } finally {
57
+ generateRequirementsProgress && generateRequirementsProgress . remove ( ) ;
34
58
}
35
- fse . ensureDirSync ( path . join ( this . servicePath , '.serverless' ) ) ;
36
- fse . writeFileSync (
37
- path . join ( this . servicePath , '.serverless/requirements.txt' ) ,
38
- removeEditableFlagFromRequirementsString ( res . stdoutBuffer )
39
- ) ;
40
59
}
41
60
42
61
/**
0 commit comments