-
Notifications
You must be signed in to change notification settings - Fork 320
Open
Description
So I have the code below and this works perfectly when I call it from Node via node index.js but once I package it using pkg and move it to /bin directory with all the files pkg says I need to ship with it stops working and there is no error output to the console and yet no notifications on windows. even though I can see via console.log code it has hit the location where it's running the code to notify again this worked perfectly via normal Node only does not work when using pkg
My bin/ file structure
/bin/index.exe
/bin/xdg-open
/bin/notifer/snoretoast-x64.exe
/bin/notifer/snoretoast-x86.exe
/bin/notifer/notifu.exe
/bin/notifer/notifu64.exe
notify.js
sendNotification = (url, picture) => {
return new Promise((resolve, reject) => {
notifier.notify(
{
title: `title`,
message: `Some Message`,
icon: picture, // Absolute path (doesn't work on balloons)
sound: true, // Only Notification Center or Windows Toasters
wait: true // Wait with callback, until user action is taken against notification, does not apply to Windows Toasters as they always wait or notify-send as it does not support the wait option
},
function (err, response, metadata) { }
);
notifier.on('click', function (notifierObject, options, event) {
// Triggers if `wait: true` and user clicks notification
if(event.action === "clicked"){
open(url); // npm install open
resolve();
}
});
});
}
module.exports = (url, profilePicture) => {
const extParts = profilePicture.split('.');
const ext = extParts[extParts.length - 1];
const osLocalPath = process.env.APPDATA || (process.platform == 'darwin' ? process.env.HOME + '/Library/Preferences' : process.env.HOME + "/.local/share");
const filePath = path.join(osLocalPath, 'TwitchNotify/');
Download.downloadFile(profilePicture, path.join(filePath,`profile_img_.${ext}`)).then( (localPath) =>{
sendNotification(url, localPath);
});
}index.js
async start(){
Notify("URL to open when clicked on", "URL to pic to use");
}
start();Metadata
Metadata
Assignees
Labels
No labels