File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed
Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -86,8 +86,8 @@ describe('index.js', () => {
8686 describe ( '#findState' , ( ) => {
8787 it ( 'should throw err - serverless.yml not exists' , ( ) => {
8888 // stepFunctionsOfflinePlugin.serverless.config = process.cwd() + '/serverless.test.yml';
89- expect ( stepFunctionsOfflinePlugin . hooks [ global [ 'hooks' ] . findState ] ) . toThrowError (
90- 'Could not find serverless manifest'
89+ stepFunctionsOfflinePlugin . hooks [ global [ 'hooks' ] . findState ] ( ) . catch ( e =>
90+ expect ( e . message ) . toEqual ( 'Could not find serverless manifest' )
9191 ) ;
9292 } ) ;
9393
Original file line number Diff line number Diff line change @@ -196,7 +196,7 @@ export default class StepFunctionsOfflinePlugin implements Plugin {
196196 } ) ;
197197 }
198198
199- getRawConfig ( ) : Promise < any > {
199+ async getRawConfig ( ) : Promise < ServerlessWithError [ 'service' ] > {
200200 const serverlessPath = this . serverless . config . servicePath ;
201201 if ( ! serverlessPath ) {
202202 throw new this . serverless . classes . Error ( 'Could not find serverless manifest' ) ;
@@ -213,9 +213,15 @@ export default class StepFunctionsOfflinePlugin implements Plugin {
213213 `Could not find serverless manifest at path ${ serverlessPath } . If this path is incorreect you should adjust the 'servicePath' variable`
214214 ) ;
215215 }
216-
216+ let fromFile : ServerlessWithError [ 'service' ] ;
217217 if ( / \. j s o n | \. j s $ / . test ( manifestFilename ) ) {
218- return import ( manifestFilename ) ;
218+ try {
219+ fromFile = await import ( manifestFilename ) ;
220+ return fromFile ;
221+ } catch ( err ) {
222+ console . error ( err ) ;
223+ throw new Error ( `Unable to import manifest at: ${ manifestFilename } ` ) ;
224+ }
219225 }
220226
221227 return this . serverless . yamlParser . parse ( manifestFilename ) ;
You can’t perform that action at this time.
0 commit comments