<commit_before>#!/usr/bin/env node

var fs = require('fs');
var path = require('path');
var util = require('util');

if(fs.existsSync('smart.json')) {
  console.log(getMeteoriteNode());
} else {
  console.log(getMeteorNode());
}


function getMeteorToolsPath() {
  try {
    var version = fs.readFileSync('.meteor/release').toString().trim();
    var releases = require(util.format('%s/.meteor/releases/%s.release.json', process.env.HOME, version));

    var toolsPath = util.format('%s/.meteor/tools/%s', process.env.HOME, releases.tools);
    return toolsPath;
  } catch(ex) {
    console.error("\nSeems like you are not in a meteor app or you haven't run app, altest once!");
    throw ex;
  }
}

function getMeteorNode() {
  if(process.env.METEOR_PATH) {
    return path.resolve(process.env.METEOR_PATH, 'dev_bundle/bin/node');
  } else {
    var toolsPath = getMeteorToolsPath();
    return path.resolve(toolsPath, 'bin/node');
  }
};

function getMeteoriteNode(appPath) {
  var smartLockFileContent = fs.readFileSync('smart.lock').toString();
  var smartLockFileJSON = JSON.parse(smartLockFileContent);

  if(smartLockFileJSON.meteor.git) {
    var repoNamespace = getGitNamespace(smartLockFileJSON.meteor.git);
    var commitSha = smartLockFileJSON.meteor.commit;
    return path.resolve(homePath, '.meteorite/meteors', repoNamespace, commitSha, 'dev_bundle/bin/node');
  } else {
    return getMeteorNode();
  }

  function getGitNamespace(gitUrl) {
    var parsed = url.parse(gitUrl);
    return parsed.path.replace(/.git$/, '').replace(/^\//, '')
  }
}<commit_msg>added METEOR_APP_PATH env variable to specify custom meteor app url<commit_after>#!/usr/bin/env node

var fs = require('fs');
var path = require('path');
var util = require('util');

var METEOR_APP_PATH = process.env.METEOR_APP_PATH || '.';

if(fs.existsSync('smart.json')) {
  console.log(getMeteoriteNode());
} else {
  console.log(getMeteorNode());
}


function getMeteorToolsPath() {
  try {
    var version = fs.readFileSync(METEOR_APP_PATH + '/.meteor/release').toString().trim();
    var releases = require(util.format('%s/.meteor/releases/%s.release.json', process.env.HOME, version));

    var toolsPath = util.format('%s/.meteor/tools/%s', process.env.HOME, releases.tools);
    return toolsPath;
  } catch(ex) {
    console.error("\nSeems like you are not in a meteor app or you haven't run app, altest once!");
    throw ex;
  }
}

function getMeteorNode() {
  if(process.env.METEOR_PATH) {
    return path.resolve(process.env.METEOR_PATH, 'dev_bundle/bin/node');
  } else {
    var toolsPath = getMeteorToolsPath();
    return path.resolve(toolsPath, 'bin/node');
  }
};

function getMeteoriteNode(appPath) {
  var smartLockFileContent = fs.readFileSync(METEOR_APP_PATH + '/smart.lock').toString();
  var smartLockFileJSON = JSON.parse(smartLockFileContent);

  if(smartLockFileJSON.meteor.git) {
    var repoNamespace = getGitNamespace(smartLockFileJSON.meteor.git);
    var commitSha = smartLockFileJSON.meteor.commit;
    return path.resolve(homePath, '.meteorite/meteors', repoNamespace, commitSha, 'dev_bundle/bin/node');
  } else {
    return getMeteorNode();
  }

  function getGitNamespace(gitUrl) {
    var parsed = url.parse(gitUrl);
    return parsed.path.replace(/.git$/, '').replace(/^\//, '')
  }
}
{'fraction_non_alphanumeric': 0.15550166717187025, 'fraction_numerical': 0.0, 'mean_word_length': 4.305466237942122, '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': '4238298', 'n_tokens_mistral': 1160, 'n_tokens_neox': 1103, 'n_words': 208}