ftpClient = new Client();
const accessResponse = await ftpClient.access({
host: uri.host,
- ...(uri.port !== '' && { port: Utils.convertToInt(uri.port) }),
- ...(uri.username !== '' && { user: uri.username }),
- ...(uri.password !== '' && { password: uri.password }),
+ ...(!Utils.isEmptyString(uri.port) && { port: Utils.convertToInt(uri.port) }),
+ ...(!Utils.isEmptyString(uri.username) && { user: uri.username }),
+ ...(!Utils.isEmptyString(uri.password) && { password: uri.password }),
});
let uploadResponse: FTPResponse;
if (accessResponse.code === 220) {
import { EmptyObject } from '../types/EmptyObject';
import { HandleErrorParams } from '../types/Error';
+import Utils from './Utils';
import chalk from 'chalk';
import logger from './Logger';
error: NodeJS.ErrnoException,
params: HandleErrorParams<EmptyObject> = { throwError: true, consoleOut: false }
): void {
- const prefix = logPrefix.length !== 0 ? logPrefix + ' ' : '';
+ const prefix = !Utils.isEmptyString(logPrefix) ? logPrefix + ' ' : '';
if (error.code === 'ENOENT') {
if (params?.consoleOut) {
console.warn(
return typeof value === 'string';
}
+ public static isEmptyString(value: unknown): boolean {
+ return Utils.isString(value) && (value as string).length === 0;
+ }
+
public static isUndefined(value: unknown): boolean {
return typeof value === 'undefined';
}