better error handling when the Next.js config can't be found, getting to 100% TypeScript

This commit is contained in:
Egor 2020-07-19 20:17:40 -07:00
parent 440ac6c6f4
commit c27fada353
4 changed files with 12 additions and 5 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "next-deploy", "name": "next-deploy",
"version": "1.0.0-alpha.0", "version": "1.0.0-alpha.1",
"description": "Effortless deployment for Next.js apps 🚀", "description": "Effortless deployment for Next.js apps 🚀",
"author": "Nidratech Ltd. <egor@nidratech.com>", "author": "Nidratech Ltd. <egor@nidratech.com>",
"keywords": [ "keywords": [
@ -23,7 +23,7 @@
"postinstall": "cd packages/aws-component && npx yarn --no-lockfile && cd ../aws-domain && npx yarn --no-lockfile && cd ../aws-lambda && npx yarn --no-lockfile && cd ../aws-lambda-builder && npx yarn --no-lockfile && cd ../cli && npx yarn --no-lockfile" "postinstall": "cd packages/aws-component && npx yarn --no-lockfile && cd ../aws-domain && npx yarn --no-lockfile && cd ../aws-lambda && npx yarn --no-lockfile && cd ../aws-lambda-builder && npx yarn --no-lockfile && cd ../cli && npx yarn --no-lockfile"
}, },
"bin": { "bin": {
"next-deploy": "./packages/cli/dist/index.js" "next-deploy": "./packages/cli/bin/next-deploy"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

View file

@ -0,0 +1,2 @@
#!/usr/bin/env node
require('../dist/index.js')

View file

@ -6,7 +6,14 @@ import Context from './context';
import { createBaseConfig } from './utils'; import { createBaseConfig } from './utils';
const deploy = async (deployConfigPath: string, methodName = 'default'): Promise<void> => { const deploy = async (deployConfigPath: string, methodName = 'default'): Promise<void> => {
const options: BaseDeploymentOptions = await import(deployConfigPath); let options: BaseDeploymentOptions;
try {
options = await import(deployConfigPath);
} catch (e) {
console.error(chalk.red(`❌ Couldn't find the Next.js config at ${deployConfigPath}`));
process.exit(1);
}
const { const {
debug = false, debug = false,
engine = DEFAULT_ENGINE, engine = DEFAULT_ENGINE,

View file

@ -1,5 +1,3 @@
#!/usr/bin/env node
import path from 'path'; import path from 'path';
import minimist from 'minimist'; import minimist from 'minimist';