<commit_before>const fs = require('fs');
const csv = require("fast-csv");
const jsforce = require('jsforce');
const sfdc = require("./salesforce");
const prompt = require('prompt');

var schema = {
    properties: {
        tool: {
            description: 'Enter your tool: Salesforce (C)ertificates or Salesforce (S)SO.',
            required: true
        },
    }
};



function promptUser() {
    prompt.start();
    prompt.get(schema, function (error, result) {
        if (error) {
            console.log(error);
        }
        if (result) {
            tool_map = {
                'c': 'certificate',
                's': 'sso'
            }
            selected_tool = tool_map[result.tool.toLowerCase()]
            if (selected_tool === undefined) {
                console.log(`Command line input ${result.tool} was unrecognized. Please try again.`)
                return promptUser();
            } else {
                console.log(`Recognized input, getting ${selected_tool} data.`)
                return selected_tool;
            }
        }
    });
}

function getCSV(fileName, tool) {
    tool_map = {
        'certificate': sfdc.getSalesforceCertificates,
        'sso': sfdc.getSalesforceSSO
    }
    selected_tool = tool_map[tool];
    fs.createReadStream(fileName)
        .pipe(csv())
        .on("data", function (data) {
            username = data[0]
            password = data[1]
            selected_tool(username, password)
        })
        .on("end", function () {
            console.log("done");
        });
}



function main() {
    tool = promptUser();
    return getCSV('secret.csv', tool)
}
<commit_msg>Move getCSv as callback of promptUser to prevent undefined evaluations.<commit_after>const fs = require('fs');
const csv = require("fast-csv");
const jsforce = require('jsforce');
const sfdc = require("./salesforce");
const prompt = require('prompt');

var schema = {
    properties: {
        tool: {
            description: 'Enter your tool: Salesforce (C)ertificates or Salesforce (S)SO.',
            required: true
        },
    }
};



function promptUser(callback) {
    prompt.start();
    prompt.get(schema, function (error, result) {
        if (error) {
            console.log(error);
        }
        if (result) {
            tool_map = {
                'c': 'certificate',
                's': 'sso'
            }
            selected_tool = tool_map[result.tool.toLowerCase()]
            if (selected_tool === undefined) {
                console.log(`Command line input ${result.tool} was unrecognized. Please try again.`)
                return promptUser();
            } else {
                console.log(`Recognized input, getting ${selected_tool} data.`)
                callback('secret.csv', selected_tool)
                //return selected_tool;
            }
        }

    });
}

function getCSV(fileName, tool) {
    tool_map = {
        'certificate': sfdc.getSalesforceCertificates,
        'sso': sfdc.getSalesforceSSO
    }
    selected_tool = tool_map[tool];
    console.log(selected_tool);
    fs.createReadStream(fileName)
        .pipe(csv())
        .on("data", function (data) {
            username = data[0]
            password = <PASSWORD>[1]
            // Selected tool is evaluated from tool_map
            selected_tool(username, password)
        })
        .on("end", function () {
            console.log("done");
        });
}



function main() {
    promptUser(getCSV);
    //return getCSV('secret.csv', tool)
}

{'fraction_non_alphanumeric': 0.13110102156640183, 'fraction_numerical': 0.0011350737797956867, 'mean_word_length': 1.8988486842105263, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '2437287', 'n_tokens_mistral': 1017, 'n_tokens_neox': 983, 'n_words': 221}