<commit_before>/* eslint no-console: 0 */

const RequestSafePasswordCommand = require( "./request-safe-password" ),
    fileSystemDriver = require( "../drivers/file-system" ),
    userConfig = require( `${process.env.HOME}/.personal-log.json` )


/**
 * Initialize a personal log file
 * This is accomplished by requesting a password from the user
 * and forcing a new file to be created with a single message: "genesis"
 * This is done so that way we can verify a password properly decrypts the
 * messages and we don't have a scenario of multiple passwords being used
 * through out the log file
 */
class InitLogFile {
    static execute() {
        return new Promise( ( resolve, reject ) => {
            let returnMessage = ""

            returnMessage += "Starting new log file ... \n"

            let message = {
                "timestamp": Date.now(),
                "user": process.env.USER,
                "message": "genesis"
            }

            RequestSafePasswordCommand.execute().then( ( password ) => {
                fileSystemDriver.destroy().then( () => {
                    returnMessage += "Log file has been destroyed... \n"

                    fileSystemDriver.saveOne( message ).then( () => {
                        returnMessage += "File has been initialized! \n"
                        resolve( returnMessage )
                    } ).catch( ( error ) => {
                        reject( error )
                    } )
                } ).catch( ( error ) => {
                    reject( error )
                } )
            } ).catch( ( error ) => {
                reject( error )
            } )
        } )
    }
}

module.exports = InitLogFile
<commit_msg>Fixed issue with init process<commit_after>/* eslint no-console: 0 */

const RequestSafePasswordCommand = require( "./request-safe-password" ),
    fileSystemDriver = require( "../drivers/file-system" ),
    userConfig = require( `${process.env.HOME}/.personal-log.json` )


/**
 * Initialize a personal log file
 * This is accomplished by requesting a password from the user
 * and forcing a new file to be created with a single message: "genesis"
 * This is done so that way we can verify a password properly decrypts the
 * messages and we don't have a scenario of multiple passwords being used
 * through out the log file
 */
class InitLogFile {
    static execute() {
        return new Promise( ( resolve, reject ) => {
            let returnMessage = ""

            returnMessage += "Starting new log file ... \n"

            let message = {
                "timestamp": Date.now(),
                "user": process.env.USER,
                "message": "genesis"
            }

            RequestSafePasswordCommand.execute().then( ( password ) => {
                fileSystemDriver.setPassword( password )
                fileSystemDriver.destroy().then( () => {
                    returnMessage += "Log file has been destroyed... \n"

                    fileSystemDriver.saveOne( message ).then( () => {
                        returnMessage += "File has been initialized! \n"
                        resolve( returnMessage )
                    } ).catch( ( error ) => {
                        reject( error )
                    } )
                } ).catch( ( error ) => {
                    reject( error )
                } )
            } ).catch( ( error ) => {
                reject( error )
            } )
        } )
    }
}

module.exports = InitLogFile

{'fraction_non_alphanumeric': 0.11136558831949614, 'fraction_numerical': 0.000572573718866304, 'mean_word_length': 1.5977695167286246, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 17, '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': '5905789', 'n_tokens_mistral': 877, 'n_tokens_neox': 821, 'n_words': 272}