1
+ /* eslint-disable no-console */
1
2
const path = require ( 'path' ) ;
2
3
const process = require ( 'process' ) ;
3
4
const fs = require ( 'fs' ) ;
@@ -9,6 +10,11 @@ const readPkg = require('read-pkg');
9
10
10
11
const serverlessPackage = require ( '../package.json' ) ;
11
12
13
+ if ( ! process . env . GITHUB_ACTIONS ) {
14
+ console . log ( `Skipping build-awslambda-layer script in local environment.` ) ;
15
+ process . exit ( 0 ) ;
16
+ }
17
+
12
18
// AWS Lambda layer are being uploaded as zip archive, whose content is then being unpacked to the /opt
13
19
// directory in the lambda environment.
14
20
//
@@ -46,12 +52,11 @@ async function collectPackages(cwd, packages = {}) {
46
52
// Internal deps aka local node_modules folder of each package is handled differently.
47
53
const searchPath = path . resolve ( cwd , '..' ) ;
48
54
const depPath = fs . realpathSync (
49
- await findUp ( path . join ( 'node_modules' , dep ) ,
50
- { type : 'directory' , cwd : searchPath } )
55
+ await findUp ( path . join ( 'node_modules' , dep ) , { type : 'directory' , cwd : searchPath } ) ,
51
56
) ;
52
57
if ( packages [ dep ] ) {
53
58
if ( packages [ dep ] . cwd != depPath ) {
54
- throw new Error ( `${ packageJson . name } 's dependenciy ${ dep } maps to both ${ packages [ dep ] . cwd } and ${ depPath } ` ) ;
59
+ throw new Error ( `${ packageJson . name } 's dependency ${ dep } maps to both ${ packages [ dep ] . cwd } and ${ depPath } ` ) ;
55
60
}
56
61
return ;
57
62
}
@@ -146,7 +151,7 @@ async function main() {
146
151
} catch ( error ) {
147
152
// The child process timed out or had non-zero exit code.
148
153
// The error contains the entire result from `childProcess.spawnSync`.
149
- console . log ( error ) ; // eslint-disable-line no-console
154
+ console . log ( error ) ;
150
155
}
151
156
}
152
157
@@ -155,7 +160,7 @@ main().then(
155
160
process . exit ( 0 ) ;
156
161
} ,
157
162
err => {
158
- console . error ( err ) ; // eslint-disable-line no-console
163
+ console . error ( err ) ;
159
164
process . exit ( - 1 ) ;
160
165
} ,
161
166
) ;
0 commit comments