Electron-builder: Is there a way to include a post-install step?

Created on 23 Mar 2017  Â·  2Comments  Â·  Source: electron-userland/electron-builder

  • Version: 16.0.1

  • Target: Mac

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.

mac question

Most helpful comment

@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.

All 2 comments

@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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AidanNichol picture AidanNichol  Â·  3Comments

NPellet picture NPellet  Â·  3Comments

StickNitro picture StickNitro  Â·  3Comments

xingoxu picture xingoxu  Â·  3Comments

lbssousa picture lbssousa  Â·  3Comments