From 1dd446c6fc6ab7bced5bb6710140a040d6153de2 Mon Sep 17 00:00:00 2001 From: Alex Mikhalev Date: Tue, 4 Sep 2018 14:50:08 -0600 Subject: [PATCH] fix: user command stuff --- server/commands/user.ts | 5 +++-- server/entities/User.ts | 7 ++----- server/repositories/UserRepository.ts | 3 +-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/server/commands/user.ts b/server/commands/user.ts index c96fe3a..b17b93b 100644 --- a/server/commands/user.ts +++ b/server/commands/user.ts @@ -14,6 +14,8 @@ type UserFlags = (typeof UserCommand)["flags"] extends Input type Action = "create" | "update" | "delete"; +// tslint:disable:no-shadowed-variable + export default class UserCommand extends ManageCommand { static description = "Manage users"; @@ -105,7 +107,7 @@ export default class UserCommand extends ManageCommand { const user = await this.getOrDeleteUser(flags, action); - if (flags.id != null && flags.username) { + if (flags.username && (flags.create || flags.id)) { user.username = flags.username; } if (flags.name) { @@ -122,7 +124,6 @@ export default class UserCommand extends ManageCommand { await this.database.users.save(user); this.log(`${capitalize(action)}d user id ${user.id} (${user.username})`); } catch (e) { - console.log(e) throw e; } } diff --git a/server/entities/User.ts b/server/entities/User.ts index 887675f..4318ef1 100644 --- a/server/entities/User.ts +++ b/server/entities/User.ts @@ -3,13 +3,10 @@ import { omit } from "lodash"; import { Column, Entity, + Index, JoinTable, ManyToMany, - PrimaryGeneratedColumn, - BeforeInsert, - BeforeUpdate, - Index, - InsertEvent + PrimaryGeneratedColumn } from "typeorm"; import { IUser } from "@common/httpApi"; diff --git a/server/repositories/UserRepository.ts b/server/repositories/UserRepository.ts index 800d37f..4a122a4 100644 --- a/server/repositories/UserRepository.ts +++ b/server/repositories/UserRepository.ts @@ -1,6 +1,5 @@ -import { EntityRepository, FindOneOptions, Repository, DeepPartial, FindConditions, SaveOptions } from "typeorm"; +import { EntityRepository, FindConditions, FindOneOptions, Repository } from "typeorm"; -import ApiError from "@common/ApiError"; import { User } from "@server/entities"; export interface FindUserOptions extends FindOneOptions {