Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #145 from ethereum/update_remixd
Browse files Browse the repository at this point in the history
Update remixd && add action to clear the cache
  • Loading branch information
yann300 authored Jul 19, 2022
2 parents 1146ed7 + 5cf5559 commit 062ac6f
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 107 deletions.
33 changes: 32 additions & 1 deletion applicationMenu.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
const {Menu, shell, app} = require('electron')
const fs = require('fs')
const path = require('path')
const config = require('./config')
const selectFolder = require('./selectFolder')

module.exports = (outdatedVersion, sharedFolderClient) => {
module.exports = (outdatedVersion, cacheDir, app, sharedFolderClient) => {

const isMac = process.platform === 'darwin'

Expand Down Expand Up @@ -136,6 +138,14 @@ const template = [
}
},
{ role: 'toggledevtools' },
{
label: 'Clear the cache and restart Remix',
click: async () => {
deleteFolderRecursive(cacheDir)
app.relaunch()
app.exit(0)
}
},
]
}
]
Expand All @@ -156,3 +166,24 @@ const menu = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(menu)

}

const deleteFolderRecursive = function (directoryPath) {
try {
if (fs.existsSync(directoryPath)) {
fs.readdirSync(directoryPath).forEach((file, index) => {
const curPath = path.join(directoryPath, file);
if (fs.lstatSync(curPath).isDirectory()) {
// recurse
deleteFolderRecursive(curPath)
} else {
// delete file
fs.unlinkSync(curPath)
}
});
fs.rmdirSync(directoryPath)
console.log(directoryPath + ' deleted')
}
} catch (e) {
console.error(e)
}
}
7 changes: 5 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const setupApplicationMenu = async () => {
console.log('unable to verify latest version')
console.log(e)
}
applicationMenu(status === 'OUTDATED', (folder) => {
applicationMenu(status === 'OUTDATED', cacheDir, app, (folder) => {
sharedFolderClient.sharedFolder(folder, false)
sharedFolderClient.setupNotifications(folder)
slitherClient.sharedFolder(folder)
Expand Down Expand Up @@ -143,7 +143,10 @@ function getFolder(client) {
}catch(e){
}
}
return os.homedir()
if (process.cwd()) {
return process.cwd()
} else
return os.homedir()
}

let remixdStart = () => {
Expand Down
Loading

0 comments on commit 062ac6f

Please sign in to comment.