Skip to content

Instantly share code, notes, and snippets.

@ef2k
Last active May 28, 2018 17:29
Show Gist options
  • Save ef2k/e75fb21d9fb10935dcdeb0463c28fea6 to your computer and use it in GitHub Desktop.
Save ef2k/e75fb21d9fb10935dcdeb0463c28fea6 to your computer and use it in GitHub Desktop.
Electron: Adding an Executable Binary

You can add files to the final asar using electron-builder's extraFiles field in package.json.

In package.json,

"build": {
  "additionalFiles": {
    "from": "resources/${os}/myBin",
    "to": "Resources/bin/myBin",
    "pattern": "**/*"
  }
}

In the main process,

import path from 'path'
import { execFile } from 'child_process'

const execPath = path.join(process.resourcesPath, 'bin/myBin')
const env = {}
execFile(execPath, { env }, (error, stdout, stderr) => {
  // do something...
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment