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
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();
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 usingpkg
and move it to /bin directory with all the filespkg
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 usingpkg
My
bin/
file structurenotify.js
index.js