From 8bc26b384e0b6a182867ff3cad1894d457291f1c Mon Sep 17 00:00:00 2001 From: Timo Hocker Date: Thu, 23 Apr 2020 17:51:19 +0200 Subject: [PATCH] fixes --- lib/snippets/database/index.ts | 2 +- .../database/patch_actions/RenameColumn.ts | 15 +++++++++++++-- lib/snippets/node/index.ts | 6 +++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/snippets/database/index.ts b/lib/snippets/database/index.ts index 91e2110..c51316c 100644 --- a/lib/snippets/database/index.ts +++ b/lib/snippets/database/index.ts @@ -2,6 +2,6 @@ import { Snippet } from '../../Snippet'; export default class Database implements Snippet { public start (): Promise { - // noop + return new Promise ((res) => res ()); } } diff --git a/lib/snippets/database/patch_actions/RenameColumn.ts b/lib/snippets/database/patch_actions/RenameColumn.ts index 19f6773..289c382 100644 --- a/lib/snippets/database/patch_actions/RenameColumn.ts +++ b/lib/snippets/database/patch_actions/RenameColumn.ts @@ -36,7 +36,18 @@ export class RenameColumn implements Serializable, PatchAction { public apply (db: Database): void { const table = db.get_table (this.table); - const column = table?.get_column(this.column); - column?.name = this.new_name; + if (typeof table === 'undefined' || table === null) { + throw new Error ( + `table ${this.table} not found` + ); + } + const column = table.get_column (this.column); + if (typeof column === 'undefined' || column === null) { + throw new Error ( + `column ${this.column} not found in table ${this.table}` + ); + } + + column.name = this.new_name; } } diff --git a/lib/snippets/node/index.ts b/lib/snippets/node/index.ts index d4f0865..ed096f4 100644 --- a/lib/snippets/node/index.ts +++ b/lib/snippets/node/index.ts @@ -6,7 +6,7 @@ */ import path from 'path'; -import { Input } from 'enquirer'; +import { Input, Confirm } from 'enquirer'; import { Snippet } from '../../Snippet'; import { apply_template, modify_json, run_command } from '../../Helper'; @@ -19,7 +19,7 @@ export default class Node implements Snippet { ) .run (); - const use_ts = await new confirm ({ + const use_ts = await new Confirm ({ message: 'use typescript?', initial: false }) @@ -50,7 +50,7 @@ export default class Node implements Snippet { test: 'nyc ava' }; if (use_ts) - obj.scripts.compile = 'tsc'; + (obj.scripts as Record).compile = 'tsc'; return obj; }, path.join (folder, 'package.json')); }