For my application, in addition to the app itself, I need to perform a minor post-install step. For my app, this is simply adding a symbolic link to the app to /usr/local/bin so that the app can be easily started from the command line.
Is there a way to include such bespoke application-specific additional setup code to be run at install time? I didn't see anything in the documentation that indicated this sort of hook.
My current plan is to just check on every invocation of the app if it is the first time this version of the app has been run (by looking for a post-install marker file that my app will create in the userData path) and perform my setup actions then. But this is somewhat inefficient and sub-optimal.
Thanks in advance for any help on this.
@antonycourtney A simpler methodology might be to just check for the existence of the symlink within /use/local/bin and create it if non-existent. This doesn't require any "first-install" logic.
fs.stat('/usr/local/bin/yourSymlink', (err, stats) => {
if(err.code == 'ENOENT') {
// file does not exist
// create symlink
}
})
This probably isn't something that electron builder can even support as not every system uses an install system to initially install your application (such as OSX which can just be a packaged .app). Though develar will correct me if I am wrong.
Yes, you can use pkg target — https://github.com/electron-userland/electron-builder/wiki/Options#PkgOptions-scripts
But I don't recommend it — better to still use DMG and create link by user request / your current solution.
Most helpful comment
@antonycourtney A simpler methodology might be to just check for the existence of the symlink within
/use/local/binand create it if non-existent. This doesn't require any "first-install" logic.This probably isn't something that electron builder can even support as not every system uses an install system to initially install your application (such as OSX which can just be a packaged .app). Though develar will correct me if I am wrong.