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

var fs = require('fs');
var path = require('path');
var run = require('./promise_spawn');
var RSVP = require('rsvp');

function maybeChangeVersion(channel) {
  if (typeof(channel) === 'undefined') {
    return RSVP.Promise.resolve('existing');
  }

  var bowerFile = path.join(__dirname, '..', 'bower.json');
  return run('git', ['checkout', bowerFile]).then(function(){
    var bowerContent = fs.readFileSync(bowerFile, 'utf-8');
    fs.writeFileSync(bowerFile, bowerContent.replace(/canary/g, channel));
    return run('bower', ['install'], {cwd: path.join(__dirname, '..')});
  }).then(function(){return channel;});
}

function logVersion(channel) {
  var got = require(path.join(__dirname, '..', 'vendor', 'ember', 'bower.json')).version;
  console.log("Based on " + channel + " I'm using version " + got);
}

maybeChangeVersion(process.env.EMBER_CHANNEL).then(function(channel){
  logVersion(channel);
  process.exit(0);
}, function(err){
  console.log(err);<commit_msg>updates to match new source structure<commit_after>#!/usr/bin/env node

var fs = require('fs');
var path = require('path');
var run = require('./promise_spawn');
var RSVP = require('rsvp');

function maybeChangeVersion(channel) {
  if (typeof(channel) === 'undefined') {
    return RSVP.Promise.resolve('existing');
  }

  var bowerFile = path.join(__dirname, '..', 'bower.json');
  return run('git', ['checkout', bowerFile]).then(function(){
    var bowerContent = fs.readFileSync(bowerFile, 'utf-8');
    fs.writeFileSync(bowerFile, bowerContent.replace(/canary/g, channel));
    return run('bower', ['install'], {cwd: path.join(__dirname, '..')});
  }).then(function(){return channel;});
}

function logVersion(channel) {
  var got = require(path.join(__dirname, '..', 'bower_components', 'ember', 'bower.json')).version;
  console.log("Based on " + channel + " I'm using version " + got);
}

maybeChangeVersion(process.env.EMBER_CHANNEL).then(function(channel){
  logVersion(channel);
  process.exit(0);
}).catch(function(err){
  console.log(err);
{'fraction_non_alphanumeric': 0.19689621726479145, 'fraction_numerical': 0.0019398642095053346, 'mean_word_length': 5.328220858895706, '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': '952226', 'n_tokens_mistral': 684, 'n_tokens_neox': 677, 'n_words': 130}