Make the avrdude binaries accessible after packaging

This commit is contained in:
Josh Stewart 2019-01-03 10:50:05 +11:00
parent 4d3a1d6ec8
commit 5dbb9902ee
3 changed files with 35 additions and 4 deletions

View File

@ -1,6 +1,7 @@
const { app, BrowserWindow, ipcMain } = require('electron')
const {download} = require('electron-dl')
const {spawn} = require('child_process');
const {execFile} = require('child_process');
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
@ -59,7 +60,8 @@ ipcMain.on('uploadFW', (e, args) => {
else if(process.platform == "darwin") { platform = "avrdude-darwin-x86"; }
else if(process.platform == "linux") { platform = "avrdude-linux_i686"; }
var executableName = "./bin/" + platform + "/avrdude";
var executableName = __dirname + "/bin/" + platform + "/avrdude";
executableName = executableName.replace('app.asar',''); //This is important for allowing the binary to be found once the app is packaed into an asar
var configName = executableName + ".conf";
if(process.platform == "win32") { executableName = executableName + '.exe'; } //This must come after the configName line above
@ -77,7 +79,9 @@ ipcMain.on('uploadFW', (e, args) => {
});
*/
const child = spawn(executableName, execArgs);
console.log(executableName);
//const child = spawn(executableName, execArgs);
const child = execFile(executableName, execArgs);
child.stdout.on('data', (data) => {
console.log(`child stdout:\n${data}`);
@ -89,6 +93,7 @@ ipcMain.on('uploadFW', (e, args) => {
child.on('error', (err) => {
console.log('Failed to start subprocess.');
console.log(err);
});
child.on('close', (code) => {

5
package-lock.json generated
View File

@ -699,6 +699,11 @@
"sumchecker": "^2.0.2"
}
},
"electron-is-running-in-asar": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/electron-is-running-in-asar/-/electron-is-running-in-asar-1.0.0.tgz",
"integrity": "sha1-9ufRapejP+R99S4/lUazcBfx+so="
},
"electron-notarize": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/electron-notarize/-/electron-notarize-0.0.5.tgz",

View File

@ -34,8 +34,29 @@
},
"build": {
"appId": "Test",
"buildDependenciesFromSource": true,
"npmRebuild": true,
"buildDependenciesFromSource": false,
"npmRebuild": false,
"files" :
[
"**/*",
"!**/node_modules/*/{CHANGELOG.md,README.md,README,readme.md,readme}",
"!**/node_modules/*/{test,__tests__,tests,powered-test,example,examples}",
"!**/node_modules/*.d.ts",
"!**/node_modules/.bin",
"!**/*.{iml,o,hprof,orig,pyc,pyo,rbc,swp,csproj,sln,xproj}",
"!.editorconfig",
"!**/._*",
"!**/{.DS_Store,.git,.hg,.svn,CVS,RCS,SCCS,.gitignore,.gitattributes}",
"!**/{__pycache__,thumbs.db,.flowconfig,.idea,.vs,.nyc_output}",
"!**/{appveyor.yml,.travis.yml,circle.yml}",
"!**/{npm-debug.log,yarn.lock,.yarn-integrity,.yarn-metadata.json}",
"!**/release-builds/*",
"bin"
],
"extraResources":
[
"bin"
],
"win": {
"icon": "assets/icons/win/icon.ico",
"target": [