Skip to content

Commit

Permalink
Refactored: move warning listener setup below imports in commit.ts
Browse files Browse the repository at this point in the history
- Moved the `process.removeAllListeners('warning')` and `process.on('warning', ...)` setup below the import statements for better code organization and readability.
- Ensured that the warning listener setup is still functional and correctly positioned to handle warnings, including `DeprecationWarning` related to `punycode`.
- This change improves the logical flow of the code by placing configuration and setup code after the necessary imports.
  • Loading branch information
SHSharkar committed Aug 16, 2024
1 parent 85e6d4e commit c742d14
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/commands/commit.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
process.removeAllListeners('warning');
process.on('warning', (warning) => {
if (warning.name === 'DeprecationWarning' && warning.message.includes('punycode')) {
return;
}
console.warn(warning);
});

import { confirm, intro, isCancel, multiselect, outro, select, spinner } from '@clack/prompts';
import chalk from 'chalk';
import { execa } from 'execa';
Expand All @@ -16,6 +8,15 @@ import { assertGitRepo, getChangedFiles, getDiff, getStagedFiles, gitAdd } from
import { trytm } from '../utils/trytm';
import { getConfig } from './config';

process.removeAllListeners('warning');
process.on('warning', (warning) => {
if (warning.name === 'DeprecationWarning' && warning.message.includes('punycode')) {
return;
}
// eslint-disable-next-line no-console
console.warn(warning);
});

const config = getConfig();

const getGitRemotes = async () => {
Expand Down

0 comments on commit c742d14

Please sign in to comment.