Skip to content

Commit

Permalink
fix: add beta password migration path (#239)
Browse files Browse the repository at this point in the history
* fix: add beta password migration path

* fix: ignore case where config yaml does not exist

* fix: remove unused dependency
  • Loading branch information
Cafe137 committed Aug 3, 2022
1 parent 962b263 commit 58d1a6a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/config-yaml.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { readFileSync, writeFileSync } from 'fs'
import { existsSync, readFileSync, writeFileSync } from 'fs'
import { dump, FAILSAFE_SCHEMA, load } from 'js-yaml'
import { getPath } from './path'

export function configYamlExists(): boolean {
return existsSync(getPath('config.yaml'))
}

export function readConfigYaml(): Record<string, unknown> {
const raw = readFileSync(getPath('config.yaml'), 'utf-8')
const data = load(raw, {
Expand Down
6 changes: 6 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ import { ensureApiKey } from './api-key'
// @ts-ignore
import squirrelInstallingExecution from 'electron-squirrel-startup'
import { initSplash } from './splash'
import { configYamlExists, readConfigYaml, writeConfigYaml } from './config-yaml'

// TODO: remove this after 1.0.0 release
// this is a migration path for pioneers
// who helped testing the early versions
if (configYamlExists() && !readConfigYaml().password) writeConfigYaml({ password: 'Test' })

if (squirrelInstallingExecution) {
app.quit()
Expand Down

0 comments on commit 58d1a6a

Please sign in to comment.