diff --git a/src/init.js b/src/init.js index 2e14035..c2bf2a0 100755 --- a/src/init.js +++ b/src/init.js @@ -90,14 +90,10 @@ function storePrefs(sendEmail, sendPass, recvEmail, recvPass, shouldStore, recvA config["password"] = sendPass; } - const configPath = tools.getConfigDir(); - if (!fs.existsSync(configPath)) { - fs.mkdirSync(configPath); - } - console.log(`${chalk.green("Login successful.")} ${nameStr}Storing your session in ${chalk.yellow(tools.getConfigDir())}...`); - fs.writeFileSync(tools.getConfigPath(), JSON.stringify(config)); - callback(null, sendApi); + tools.saveConfig(config, err => { + callback(err, sendApi); + }); }); }); }); diff --git a/src/tools.js b/src/tools.js index 4214bba..3fe63ee 100644 --- a/src/tools.js +++ b/src/tools.js @@ -27,6 +27,11 @@ exports.loadConfig = () => { } exports.saveConfig = (config, callback = () => { }) => { + const configPath = this.getConfigDir(); + if (!fs.existsSync(configPath)) { + fs.mkdirSync(configPath); + } + fs.writeFile(this.getConfigPath(), JSON.stringify(config), callback); }