message: Make predicates & transformers into functions
diff: @@ -14,6 +14,22 @@ import commands from './commands';
  import type { AmazeeConfig } from './parseConfig';
  +const getErrorMessageArgs = err =>
  + R.cond([
  + // If a `stack` property exists on the error object, use that
  + [R.prop('stack'), ({ stack }) => ['UNCAUGHT ERROR: %s', stack]],
  + // If the error is an object without a `stack` property and isn't null, stringify it
  + [
  + R.allPass(R.is(Object), !R.equals(null)),
  + errWithoutStack => [
  + 'UNCAUGHT ERROR: %s',
  + JSON.stringify(errWithoutStack, null, 2),
  + ],
  + ],
  + // Otherwise, just blindly print it
  + [R.T, nonObjectErr => ['UNCAUGHT ERROR:', nonObjectErr]],
  + ])(err);
  +
  /**
  * Finds and reads the amazeeio.yml file
  */
  @@ -32,17 +48,8 @@ async function readConfig(cwd: string): Promise<?AmazeeConfig> {
  * Used for logging unexpected errors raised by subcommands
  */
  function errorQuit(err: Error | Object | string) {
  - const stack = R.prop('stack', err);
  -
  - const errorMessageArgs = R.cond([
  - [stack, ['UNCAUGHT ERROR: %s', stack]],
  - [typeof err === 'object' && err !== null, ['UNCAUGHT ERROR: %s', JSON.stringify(err, null, 2)]],
  - [R.T, ['UNCAUGHT ERROR:', err]],
  - ]);
  -
  // eslint-disable-next-line no-console
  - console.error(...errorMessageArgs);
  -
  + console.error(...getErrorMessageArgs(err));
  process.exit(1);
  }
  