Add auto save and load
This commit is contained in:
parent
9cabbc8813
commit
93ac1a980e
4 changed files with 11 additions and 2 deletions
|
|
@ -13,11 +13,15 @@ const load = () => {
|
|||
return;
|
||||
}
|
||||
|
||||
console.log("loading data...");
|
||||
|
||||
const json = readFileSync(config.storePath).toString();
|
||||
state = JSON.parse(json) as IState;
|
||||
};
|
||||
|
||||
const save = () => {
|
||||
console.log("saving data...");
|
||||
|
||||
const json = JSON.stringify(state);
|
||||
writeFileSync(config.storePath, json);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue