<commit_before>import fs from 'fs';
import _ from 'lodash';
import path from 'path';
import read from 'read';
import User from './model/user';

const CONFIG_FILENAME = '.urionlinejudge.json';
let user;

export default function loadUser(reset) {
    let save = false;

    return _loadUser(reset)
        .then(() => {
            if (_.isEmpty(user.username)) {
                save = true;
                return _askForUsername();
            }
        })
        .then(() => {
            if (_.isEmpty(user.email)) {
                save = true;
                return _askForEmail();
            }
        })
        .then(() => {
            if (_.isEmpty(user.password)) {
                save = true;
                return _askForPassword();
            }
        })
        .then(() => {
            if (save) {
                return _save();
            }
        });
}

function _loadUser(reset) {
    const exists = fs.existsSync(_getConfigPath());
    let userConfigJSON = {};

    if (exists && !reset) {
        const userConfigPath = _getConfigPath();
        userConfigJSON = JSON.parse(fs.readFileSync(userConfigPath));
    }

    user = new User(userConfigJSON);

    return Promise.resolve();
}

function _askForEmail() {
    return _ask({
            prompt: 'What is your email?',
        })
        .then(answer => {<commit_msg>fix: return user at the end<commit_after>import fs from 'fs';
import _ from 'lodash';
import path from 'path';
import read from 'read';
import User from './model/user';

const CONFIG_FILENAME = '.urionlinejudge.json';
let user;

export default function loadUser(reset) {
    let save = false;

    return _loadUser(reset)
        .then(() => {
            if (_.isEmpty(user.username)) {
                save = true;
                return _askForUsername();
            }
        })
        .then(() => {
            if (_.isEmpty(user.email)) {
                save = true;
                return _askForEmail();
            }
        })
        .then(() => {
            if (_.isEmpty(user.password)) {
                save = true;
                return _askForPassword();
            }
        })
        .then(() => {
            if (save) {
                return _save();
            }
        })
        .then(() => user);
}

function _loadUser(reset) {
    const exists = fs.existsSync(_getConfigPath());
    let userConfigJSON = {};

    if (exists && !reset) {
        const userConfigPath = _getConfigPath();
        userConfigJSON = JSON.parse(fs.readFileSync(userConfigPath));
    }

    user = new User(userConfigJSON);

    return Promise.resolve();
}

function _askForEmail() {
    return _ask({
            prompt: 'What is your email?',
        })
        .then(answer => {
{'fraction_non_alphanumeric': 0.1325564457392571, 'fraction_numerical': 0.0, 'mean_word_length': 1.6413461538461538, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5726297', 'n_tokens_mistral': 785, 'n_tokens_neox': 756, 'n_words': 185}