mirror of
https://github.com/opelly27/streetmerchant.git
synced 2026-05-20 09:57:38 +00:00
fix: color logs and notification
Signed-off-by: Jef LeCompte <jeffreylec@gmail.com>
This commit is contained in:
+14
-13
@@ -5,29 +5,30 @@ import playerLib from 'play-sound';
|
||||
|
||||
const notificationSound = Config.notifications.playSound;
|
||||
|
||||
Logger.info('ℹ searching for sound player...');
|
||||
const player = playerLib();
|
||||
|
||||
if (player.player === null) {
|
||||
Logger.warn('No sound player found.');
|
||||
Logger.warn('✖ couldn\'t find sound player');
|
||||
} else {
|
||||
const playerName: string = player.player;
|
||||
Logger.info(`✔ sound player found: ${playerName}`);
|
||||
}
|
||||
|
||||
export function playSound() {
|
||||
// Check if file exists
|
||||
fs.access(notificationSound, fs.constants.F_OK, error => {
|
||||
if (error) {
|
||||
Logger.error(`✖ error opening sound file: ${error.message}`);
|
||||
return;
|
||||
}
|
||||
|
||||
player.play(notificationSound, (error: Error) => {
|
||||
if (player.player !== null) {
|
||||
fs.access(notificationSound, fs.constants.F_OK, error => {
|
||||
if (error) {
|
||||
Logger.error('✖ couldn\'t play sound', error);
|
||||
Logger.error(`✖ error opening sound file: ${error.message}`);
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.info('✔ played sound');
|
||||
player.play(notificationSound, (error: Error) => {
|
||||
if (error) {
|
||||
Logger.error('✖ couldn\'t play sound', error);
|
||||
}
|
||||
|
||||
Logger.info('✔ played sound');
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user