Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Is it possible to use windows-shortcuts with pkg?? #814

Closed
trepichio opened this issue Dec 19, 2019 · 3 comments
Closed

Is it possible to use windows-shortcuts with pkg?? #814

trepichio opened this issue Dec 19, 2019 · 3 comments

Comments

@trepichio
Copy link

I’m using windows-shortcuts in my project to create a few windows desktop shortcuts. It works fine running on Node, but after pkg it won’t because I think it cannot resolve the external path or the variable %UserProfle%.
I’ve tried using path.resolve and join, with process.cwd() as base argument.

Any suggestions how could I achieve that?

@trepichio trepichio changed the title How to reach %UserProfile% with pkg? Is it possible to use windows-shortcuts with pkg?? Dec 22, 2019
@wizebin
Copy link

wizebin commented Dec 26, 2019

You could try debugging using the --inspect flag
#93 (comment)

Then pause your code where it's failing and step through

You may want to look specifically at this line https://github.com/j201/windows-shortcuts/blob/master/lib/windows-shortcuts.js#L61

I'm not sure what's present in your process.env, you may need to manually set the corresponding environment variables manually if they're not being passed by pkg

@trepichio
Copy link
Author

trepichio commented Dec 26, 2019

Thanks for the reply!
I kind of fixed this issue by using require('os').homedir() and copying the Shortcut.exe to outside of snapshot, into process.cwd().
Then, I replaced in windows-shortcuts.js those lines where contains __dirname by process.cwd()
It works fine now!

However, I'm facing another issue.
I want to delete this external Shortcut.exe after creating several shortcuts, but I am not being able to.
I've tried using fs.unlinkSync and shelljs.rm and both works great for other files but not this one. I think it's because of some delay to execute the callbacks of each ws.create but they don't return a Promise or anything at all to be able to track.
I've tried to add each ws.create call to an array and pass them to Promise.all but it's not working too.

How can I track when all ws.create are totally done and then being able to delete the .exe?

@trepichio
Copy link
Author

For future reference to anyone interested I've got an idea here to solve the issue: https://stackoverflow.com/questions/31372351/track-completion-of-javascript-callbacks-without-nesting-functions

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants