<commit_before>/**
 * Appcelerator Common Library for Node.js
 * Copyright (c) 2012 by Appcelerator, Inc. All Rights Reserved.
 * Please see the LICENSE file for information about licensing.
 */

var exec = require('child_process').exec,
	async = require('async'),
	path = require('path'),
	util = require('./util'),
	fs = require('fs'),
	afs = require('./fs'),
	version = require('./version'),
	cached,
	MIN_API_LEVEL = 7;

exports.detect = function (finished, sdkPath, ndkPath) {
	if (cached) return finished(cached);
	
	if (!sdkPath) {
		sdkPath = process.env.ANDROID_SDK || '';
	}
	
	if (!ndkPath) {
		ndkPath = process.env.ANDROID_NDK || '';
	}
	
	var result = {
			sdkPath: sdkPath,
			java: {
				version: '',
				build: ''
			},
			ndk: {
				path: ndkPath,
				version: ''
			},
			targets: {},
			avds: []
		};
	
	if (!result.sdkPath || !afs.exists(result.sdkPath)) {
		sdkPath = result.sdkPath = findSDK();
	}
	var exe = result.exe = path.join(sdkPath, 'tools', process.platform == 'win32' ? 'android.bat' : 'android');
	if (!afs.exists(exe)) {
		finished && finished();
		return;
	}
	if (exe.indexOf(' ') != -1) {
		if (process.platform === 'win32') {
			exe = '"' + exe + '"';
		} else {
			exe = exe.replace(' ', '\\ ');
		}
	}

	async.series([
		
		function (next) {
			if (result.ndk.path) {
				try {	
					result.ndk.version = fs.readFileSync(path.join(result.ndk.path, "RELEASE.TXT")).toString().trim();
				} catch(e) { // Path doesn't exist
					result.ndk.path = '';
				}
			}
			next();
		},
		
		function (next) {
			exec('javac -version', function (err, stdout, stderr) {
				if (!err) {<commit_msg>Small update to android lib.<commit_after>/**
 * Appcelerator Common Library for Node.js
 * Copyright (c) 2012 by Appcelerator, Inc. All Rights Reserved.
 * Please see the LICENSE file for information about licensing.
 */

var exec = require('child_process').exec,
	async = require('async'),
	path = require('path'),
	util = require('./util'),
	fs = require('fs'),
	afs = require('./fs'),
	version = require('./version'),
	cached,
	MIN_API_LEVEL = 7;

exports.detect = function (finished, sdkPath, ndkPath) {
	if (cached) return finished(cached);
	
	var result = {
		sdkPath: sdkPath = sdkPath || process.env.ANDROID_SDK || '',
		java: {
			version: '',
			build: ''
		},
		ndk: {
			path: ndkPath = ndkPath || process.env.ANDROID_NDK || '',
			version: ''
		},
		targets: {},
		avds: []
	};
	
	if (!sdkPath || !afs.exists(sdkPath)) {
		sdkPath = result.sdkPath = findSDK();
	}
	
	var exe = result.exe = path.join(sdkPath, 'tools', process.platform == 'win32' ? 'android.bat' : 'android');
	if (!afs.exists(exe)) {
		finished && finished();
		return;
	}
	
	if (exe.indexOf(' ') != -1) {
		if (process.platform === 'win32') {
			exe = '"' + exe + '"';
		} else {
			exe = exe.replace(' ', '\\ ');
		}
	}

	async.series([
		
		function (next) {
			if (result.ndk.path) {
				try {	
					result.ndk.version = fs.readFileSync(path.join(result.ndk.path, "RELEASE.TXT")).toString().trim();
				} catch(e) { // Path doesn't exist
					result.ndk.path = '';
				}
			}
			next();
		},
		
		function (next) {
			exec('javac -version', function (err, stdout, stderr) {
				if (!err) {
{'fraction_non_alphanumeric': 0.19349796811503595, 'fraction_numerical': 0.006251953735542357, 'mean_word_length': 3.0302267002518892, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '711647', 'n_tokens_mistral': 1341, 'n_tokens_neox': 1148, 'n_words': 256}