1+ /* eslint-disable no-console */
12const path = require ( 'path' ) ;
23const process = require ( 'process' ) ;
34const fs = require ( 'fs' ) ;
@@ -9,6 +10,11 @@ const readPkg = require('read-pkg');
910
1011const serverlessPackage = require ( '../package.json' ) ;
1112
13+ if ( ! process . env . GITHUB_ACTIONS ) {
14+ console . log ( `Skipping build-awslambda-layer script in local environment.` ) ;
15+ process . exit ( 0 ) ;
16+ }
17+
1218// AWS Lambda layer are being uploaded as zip archive, whose content is then being unpacked to the /opt
1319// directory in the lambda environment.
1420//
@@ -46,12 +52,11 @@ async function collectPackages(cwd, packages = {}) {
4652 // Internal deps aka local node_modules folder of each package is handled differently.
4753 const searchPath = path . resolve ( cwd , '..' ) ;
4854 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 } ) ,
5156 ) ;
5257 if ( packages [ dep ] ) {
5358 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 } ` ) ;
5560 }
5661 return ;
5762 }
@@ -146,7 +151,7 @@ async function main() {
146151 } catch ( error ) {
147152 // The child process timed out or had non-zero exit code.
148153 // The error contains the entire result from `childProcess.spawnSync`.
149- console . log ( error ) ; // eslint-disable-line no-console
154+ console . log ( error ) ;
150155 }
151156}
152157
@@ -155,7 +160,7 @@ main().then(
155160 process . exit ( 0 ) ;
156161 } ,
157162 err => {
158- console . error ( err ) ; // eslint-disable-line no-console
163+ console . error ( err ) ;
159164 process . exit ( - 1 ) ;
160165 } ,
161166) ;
0 commit comments