fix: color logs and notification

Signed-off-by: Jef LeCompte <jeffreylec@gmail.com>
This commit is contained in:
Jef LeCompte
2020-09-23 18:43:25 -04:00
parent a154e95681
commit 76b28a6dbd
4 changed files with 53 additions and 28 deletions
+14 -13
View File
@@ -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');
});
});
});
}
}