mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
Reject promise and handle exit code in the wrapper
This commit is contained in:
parent
fb1b4ef14a
commit
b5284df55f
@ -17,4 +17,7 @@ process.noDeprecation = true;
|
||||
});
|
||||
|
||||
return serverless.init().then(() => serverless.run());
|
||||
}).catch(e => logError(e)))();
|
||||
}).catch(e => {
|
||||
process.exitCode = 1;
|
||||
logError(e);
|
||||
}))();
|
||||
|
||||
@ -120,7 +120,7 @@ class AwsInvoke {
|
||||
}
|
||||
|
||||
if (invocationReply.FunctionError) {
|
||||
process.exit(1);
|
||||
return BbPromise.reject(new Error("Invoked function errored"));
|
||||
}
|
||||
|
||||
return BbPromise.resolve();
|
||||
|
||||
@ -260,8 +260,7 @@ describe('AwsInvoke', () => {
|
||||
return awsInvoke.log(invocationReplyMock);
|
||||
});
|
||||
|
||||
it('should exit on error', () => {
|
||||
const exit = sinon.stub(process, 'exit');
|
||||
it('rejects the promise for failed invocations', (done) => {
|
||||
const invocationReplyMock = {
|
||||
Payload: `
|
||||
{
|
||||
@ -272,8 +271,11 @@ describe('AwsInvoke', () => {
|
||||
FunctionError: true,
|
||||
};
|
||||
|
||||
awsInvoke.log(invocationReplyMock);
|
||||
expect(exit.calledWithExactly(1)).to.be.equal(true);
|
||||
awsInvoke.log(invocationReplyMock).then(p => {
|
||||
done(new Error("Promise resolved"));
|
||||
}, (e) => {
|
||||
done()
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user