<commit_before>/**
 * Created by prism on 4/8/14.
 */
var client = require('phonegap-build-api');
var os = require('os').platform()
    config = require('./auth.js');
//client.auth({ username: config.username, password: <PASSWORD> }, function(e, api) {
//    // time to make requests
//    console.log(e);
//    console.log(api);
//    console.log(os);
//    console.log(process.ENV);
//});

var home = require('homedir');
console.log(home());<commit_msg>Implemented login and logged out functions<commit_after>/**
 * Created by prism on 4/8/14.
 */
'use strict';

var client = require('phonegap-build-api');
var os = require('os').platform(),
    fs = require('fs'),
    home = require('homedir'),
    color = require('cli-color');
config = require('./auth.js');
//client.auth({ username: config.username, password: <PASSWORD> }, function(e, api) {
//    // time to make requests
//    console.log(e);
//    console.log(api);
//    console.log(os);
//    console.log(process.ENV);
//});

var location = home() + "/.HirenGap";


function dir() {
    //todo windows support
    fs.exists(location, function (exists) {
        //console.log(exists ? "it's there" : "no passwd!");
        if (!exists) {
            fs.mkdirSync(location); // todo permission
            fs.openSync(location + "/token", 'w');
        }
    });
}

function login() {
    dir();
    fs.exists(location + '/token', function (exists) {
        if (!exists) {
            client.auth({ username: config.username, password: <PASSWORD> }, function (e, api) {
                if (e) console.log("Ops login error, error details : ", e);
                fs.writeFileSync(location + "/token", api.token);
            });
        }
    });

}

function logout() {
    fs.exists(location + '/token', function (exists) {
        if (exists) {
            fs.unlinkSync(location + '/token');
            console.log("Logged Out!");
        }
    });
}
login();
{'fraction_non_alphanumeric': 0.19418483904465214, 'fraction_numerical': 0.004153686396677051, 'mean_word_length': 2.4972776769509983, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '2661718', 'n_tokens_mistral': 608, 'n_tokens_neox': 594, 'n_words': 140}