- const prefix = !Utils.isEmptyString(logPrefix) ? logPrefix + ' ' : '';
- if (error.code === 'ENOENT') {
- if (params?.consoleOut) {
- console.warn(
- chalk.green(prefix) + chalk.yellow(fileType + ' file ' + file + ' not found: '),
- error
- );
- } else {
- logger.warn(prefix + fileType + ' file ' + file + ' not found: %j', error);
- }
- } else if (error.code === 'EEXIST') {
- if (params?.consoleOut) {
- console.warn(
- chalk.green(prefix) + chalk.yellow(fileType + ' file ' + file + ' already exists: '),
- error
- );
- } else {
- logger.warn(prefix + fileType + ' file ' + file + ' already exists: %j', error);
- }
- } else if (error.code === 'EACCES') {
- if (params?.consoleOut) {
- console.warn(
- chalk.green(prefix) + chalk.yellow(fileType + ' file ' + file + ' access denied: '),
- error
- );
- } else {
- logger.warn(prefix + fileType + ' file ' + file + ' access denied: %j', error);
- }
+ const prefix = Utils.isNotEmptyString(logPrefix) ? `${logPrefix} ` : '';
+ let logMsg: string;
+ switch (error.code) {
+ case 'ENOENT':
+ logMsg = `${fileType} file ${file} not found:`;
+ break;
+ case 'EEXIST':
+ logMsg = `${fileType} file ${file} already exists:`;
+ break;
+ case 'EACCES':
+ logMsg = `${fileType} file ${file} access denied:`;
+ break;
+ default:
+ logMsg = `${fileType} file ${file} error:`;
+ }
+ if (params?.consoleOut) {
+ logMsg = `${logMsg} `;
+ console.warn(`${chalk.green(prefix)}${chalk.yellow(logMsg)}`, error);