Skip to content

Commit

Permalink
refactored b
Browse files Browse the repository at this point in the history
  • Loading branch information
AnatolyUss committed Sep 15, 2020
1 parent b13451a commit 51ae885
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/BinaryDataDecoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { PoolClient } from 'pg';
/**
* Decodes binary data from from textual representation in string.
*/
export default async function (conversion: Conversion): Promise<Conversion> {
export default async (conversion: Conversion): Promise<Conversion> => {
const logTitle: string = 'BinaryDataDecoder::decodeBinaryData';
log(conversion, `\t--[${ logTitle }] Decodes binary data from textual representation in string.`);

Expand Down Expand Up @@ -67,4 +67,4 @@ export default async function (conversion: Conversion): Promise<Conversion> {

await Promise.all(decodePromises);
return conversion;
}
};
20 changes: 10 additions & 10 deletions src/BootProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { getStateLogsTableName } from './MigrationStateManager';
/**
* Checks correctness of connection details of both MySQL and PostgreSQL.
*/
export async function checkConnection(conversion: Conversion): Promise<string> {
export const checkConnection = async (conversion: Conversion): Promise<string> => {
let resultMessage: string = '';
const params: IDBAccessQueryParams = {
conversion: conversion,
Expand All @@ -48,12 +48,12 @@ export async function checkConnection(conversion: Conversion): Promise<string> {
const pgResult: DBAccessQueryResult = await DBAccess.query(params);
resultMessage += pgResult.error ? `\tPostgreSQL connection error: ${ JSON.stringify(pgResult.error) }` : '';
return resultMessage;
}
};

/**
* Returns Nmig's logo.
*/
export function getLogo(): string {
export const getLogo = (): string => {
return '\n\t/\\_ |\\ /\\/\\ /\\___'
+ '\n\t| \\ | |\\ | | | __'
+ '\n\t| |\\\\| || | | | \\_ \\'
Expand All @@ -62,12 +62,12 @@ export function getLogo(): string {
+ '\n\n\tNMIG - the database migration tool'
+ '\n\tCopyright (C) 2016 - present, Anatoly Khaytovich <[email protected]>\n\n'
+ '\t--[boot] Configuration has been just loaded.';
}
};

/**
* Boots the migration.
*/
export function boot(conversion: Conversion): Promise<Conversion> {
export const boot = (conversion: Conversion): Promise<Conversion> => {
return new Promise<Conversion>(async resolve => {
const connectionErrorMessage = await checkConnection(conversion);
const logo: string = getLogo();
Expand Down Expand Up @@ -97,7 +97,7 @@ export function boot(conversion: Conversion): Promise<Conversion> {

console.log(logo + message);

const _getUserInput = (input: string) => {
const _getUserInput = (input: string): void => {
const trimedInput: string = input.trim();

if (trimedInput === 'n' || trimedInput === 'N') {
Expand All @@ -122,7 +122,7 @@ export function boot(conversion: Conversion): Promise<Conversion> {
.setEncoding(conversion._encoding)
.on('data', _getUserInput);
});
}
};

/**
* Parses CLI input arguments, if given.
Expand All @@ -132,9 +132,9 @@ export function boot(conversion: Conversion): Promise<Conversion> {
* npm start -- --conf-dir='C:\Users\anatolyuss\Documents\projects\nmig_config' --logs-dir='C:\Users\anatolyuss\Documents\projects\nmig_logs'
* npm test -- --conf-dir='C:\Users\anatolyuss\Documents\projects\nmig_config' --logs-dir='C:\Users\anatolyuss\Documents\projects\nmig_logs'
*/
export function getConfAndLogsPaths(): IConfAndLogsPaths {
export const getConfAndLogsPaths = (): IConfAndLogsPaths => {
const baseDir: string = path.join(__dirname, '..', '..');
const _parseInputArguments = (paramName: string) => {
const _parseInputArguments = (paramName: string): string | undefined => {
const _path: string | undefined = process.argv.find((arg: string) => arg.startsWith(paramName));
return _path ? _path.split('=')[1] : undefined;
};
Expand All @@ -143,4 +143,4 @@ export function getConfAndLogsPaths(): IConfAndLogsPaths {
confPath: _parseInputArguments('--conf-dir') || path.join(baseDir, 'config'),
logsPath: _parseInputArguments('--logs-dir') || baseDir
};
}
};

0 comments on commit 51ae885

Please sign in to comment.