Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows pkg does not work #427

Open
barkermn01 opened this issue Jan 23, 2023 · 0 comments
Open

Windows pkg does not work #427

barkermn01 opened this issue Jan 23, 2023 · 0 comments

Comments

@barkermn01
Copy link

barkermn01 commented Jan 23, 2023

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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant