-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from qlrd/main
Addition of wipe feature Correction of records that were overlapped between flash sessions
- Loading branch information
Showing
25 changed files
with
765 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/// <reference path="../typings/index.d.ts"/> | ||
|
||
import ElectronStore from 'electron-store'; | ||
import Handler from './handler' | ||
import { glob } from 'glob' | ||
|
||
export default class CheckIfItWillWipeHandler extends Handler { | ||
|
||
constructor (win: Electron.BrowserWindow, storage: ElectronStore, ipcMain: Electron.IpcMain) { | ||
super('krux:check:will:wipe', win, storage, ipcMain); | ||
} | ||
|
||
/** | ||
* Builds a `handle` method for `ipcMain` to be called | ||
* with `invoke` method in `ipcRenderer`. | ||
* | ||
* @example | ||
* ``` | ||
* // check if all requirements to flash | ||
* // a firmware are meet (i.e. files for device) | ||
* methods: { | ||
* async download () { | ||
* await window.api.invoke('krux:check:will:flash') | ||
* | ||
* window.api.onSuccess('krux:store:set', function(_, isChanged) { | ||
* // ... do something | ||
* }) | ||
* | ||
* window.api.onError('krux:check:will:flash', function(_, error) { | ||
* // ... do something | ||
* }) | ||
* } | ||
* } | ||
* | ||
* ``` | ||
*/ | ||
build () { | ||
super.build(async (options) => { | ||
const device = this.storage.get('device') as string | ||
const resources = this.storage.get('resources') as string | ||
|
||
if (device.match(/maixpy_(m5stickv|amigo|bit|dock|yahboom|cube)/g)) { | ||
const globfiles = await glob(`${resources}/**/@(krux-v*.zip|ktool-*)`) | ||
|
||
if (globfiles.length > 0) { | ||
this.send(`${this.name}:success`, { showWipe: true }) | ||
} else { | ||
console.log('no found') | ||
this.send(`${this.name}:success`, { showWipe: false }) | ||
} | ||
} else { | ||
this.send(`${this.name}:success`, { showWipe: false }) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.