Skip to content

Commit abd8f74

Browse files
authored
Merge pull request #121 from arduino/bugfix/extra-resource
Extra resource
2 parents d16a173 + 8b085dc commit abd8f74

File tree

4 files changed

+34
-3
lines changed

4 files changed

+34
-3
lines changed

backend/ipc.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,15 @@ module.exports = function registerIPCHandlers(win, ipcMain, app) {
113113
app.exit()
114114
})
115115

116+
ipcMain.handle('is-packaged', () => {
117+
return app.isPackaged
118+
})
119+
120+
ipcMain.handle('get-app-path', () => {
121+
console.log('ipcMain', 'get-app-path')
122+
return app.getAppPath()
123+
})
124+
116125
win.on('close', (event) => {
117126
console.log('BrowserWindow', 'close')
118127
event.preventDefault()

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"build": {
2222
"appId": "cc.arduino.micropython-lab",
2323
"artifactName": "${productName}-${os}_${arch}.${ext}",
24+
"extraResources": "./ui/arduino/helpers.py",
2425
"mac": {
2526
"target": "zip",
2627
"icon": "build_resources/icon.icns"

preload.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ const Disk = {
145145
},
146146
fileExists: async (filePath) => {
147147
return ipcRenderer.invoke('file-exists', filePath)
148+
},
149+
getAppPath: () => {
150+
return ipcRenderer.invoke('get-app-path')
148151
}
149152
}
150153

@@ -153,7 +156,8 @@ const Window = {
153156
ipcRenderer.invoke('set-window-size', minWidth, minHeight)
154157
},
155158
beforeClose: (callback) => ipcRenderer.on('check-before-close', callback),
156-
confirmClose: () => ipcRenderer.invoke('confirm-close')
159+
confirmClose: () => ipcRenderer.invoke('confirm-close'),
160+
isPackaged: () => ipcRenderer.invoke('is-packaged')
157161
}
158162

159163

ui/arduino/store.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,7 @@ function canEdit({ selectedFiles }) {
14901490

14911491
async function removeBoardFolder(fullPath) {
14921492
// TODO: Replace with getting the file tree from the board and deleting one by one
1493-
let output = await serial.execFile('./ui/arduino/helpers.py')
1493+
let output = await serial.execFile(await getHelperFullPath())
14941494
await serial.run(`delete_folder('${fullPath}')`)
14951495
}
14961496

@@ -1522,7 +1522,7 @@ async function uploadFolder(srcPath, destPath, dataConsumer) {
15221522
async function downloadFolder(srcPath, destPath, dataConsumer) {
15231523
dataConsumer = dataConsumer || function() {}
15241524
await disk.createFolder(destPath)
1525-
let output = await serial.execFile('./ui/arduino/helpers.py')
1525+
let output = await serial.execFile(await getHelperFullPath())
15261526
output = await serial.run(`ilist_all('${srcPath}')`)
15271527
let files = []
15281528
try {
@@ -1550,3 +1550,20 @@ async function downloadFolder(srcPath, destPath, dataConsumer) {
15501550
}
15511551
}
15521552
}
1553+
1554+
async function getHelperFullPath() {
1555+
const appPath = await disk.getAppPath()
1556+
if (await win.isPackaged()) {
1557+
return disk.getFullPath(
1558+
appPath,
1559+
'..',
1560+
'ui/arduino/helpers.py'
1561+
)
1562+
} else {
1563+
return disk.getFullPath(
1564+
appPath,
1565+
'ui/arduino/helpers.py',
1566+
''
1567+
)
1568+
}
1569+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy