claudiajs / claudia

Deploy Node.js projects to AWS Lambda and API Gateway easily
https://claudiajs.com
MIT License
3.8k stars 274 forks source link

claudia failures close process #182

Closed mklaber closed 5 years ago

mklaber commented 5 years ago

It's entirely possible I'm being daft or have some how messed up my own node.js (v9.11.1 via nvm) installation but I've been unable to replicate the following behaviour with anything except Claudia.

tl;dr: claudia errors terminate my macOS Terminal session

When running a claudia command that (legitimately) fails on macOS, I expect an error to be printed to the terminal and claudia to exit leaving the terminal ready for another command.

When running a claudia command that (legitimately) fails, my macOS Terminal session is terminated.

No need to create a project, just follow these steps:

npm i claudia -g
claudia create --name hello-world --region eu-west-1 --handler main.handler --config some-config.json

Output:

package.json does not exist in the source folder
Saving session...completed.

[Process completed]

image

I tried replicating the error handling from cmd.js in a separate file:

console.error('some error');
process.exit(1);

And node some-test-file.js

And it did not close the Terminal.

gojko commented 5 years ago

what terminal program are you using? exiting a process with code 1 should be perfectly legitimate to stop with an error, and this works OK on my MacOs terminal.

mklaber commented 5 years ago

macOS's Terminal.

I am no longer able to reproduce this consistently so will close this issue.

mklaber commented 5 years ago

For reference, I figured it out. I've got a script that I was running to set my local environment variables before running claudia. The script (set-env.sh) looks like:

#!/usr/bin/env bash

set -e

export $(egrep -v '^#' .env | xargs)

I then executed it by doing . set-env.sh

The problematic line is the set -e which was causing the Terminal to exit.

@gojko is there/can there be support for dotenv for the CLI tool?