<commit_before>'use babel';

import {Emitter} from 'atom';
import CSON from 'season';
import fs from 'fs';
import path from 'path';
import os from 'os';
import _ from 'underscore-plus';

export default class DB {
  constructor() {
    this.emitter = new Emitter();
    this.updaters = {};

    this.onUpdate((projects) => {
      for (let project of projects) {
        this.sendUpdate(project);
      }
    });

    fs.exists(this.file(), (exists) => {
      if (exists) {
        this.observeProjects();
      } else {
        this.writeFile({});
      }
    });
  }

  get environmentSpecificProjects() {
    return atom.config.get('project-manager.environmentSpecificProjects');
  }

  find(callback=null) {
    this.readFile(results => {
      let projects = [];
      let result = null;
      let template = null;
      let key;

      for (key in results) {
        result = results[key];
        template = result.template || null;
        result._id = key;

        if (template && results[template] !== null) {
          result = _.deepExtend(result, results[template]);
        }

        for (let i in result.paths) {
          if (typeof result.paths[i] !== 'string') {
            continue;
          }

          if (result.paths[i].charAt(0) === '~') {
            result.paths[i] = result.paths[i].replace('~', os.homedir());
          }
        }

        projects.push(result);
      }

      if (callback) {
        callback(projects);
      }
    });<commit_msg>No need to let template through<commit_after>'use babel';

import {Emitter} from 'atom';
import CSON from 'season';
import fs from 'fs';
import path from 'path';
import os from 'os';
import _ from 'underscore-plus';

export default class DB {
  constructor() {
    this.emitter = new Emitter();
    this.updaters = {};

    this.onUpdate((projects) => {
      for (let project of projects) {
        this.sendUpdate(project);
      }
    });

    fs.exists(this.file(), (exists) => {
      if (exists) {
        this.observeProjects();
      } else {
        this.writeFile({});
      }
    });
  }

  get environmentSpecificProjects() {
    return atom.config.get('project-manager.environmentSpecificProjects');
  }

  find(callback=null) {
    this.readFile(results => {
      let projects = [];
      let result = null;
      let template = null;
      let key;

      for (key in results) {
        result = results[key];
        template = result.template || null;
        result._id = key;

        if (typeof result.paths === 'undefined') {
          continue;
        }

        if (template && results[template] !== null) {
          result = _.deepExtend(result, results[template]);
        }

        for (let i in result.paths) {
          if (typeof result.paths[i] !== 'string') {
            continue;
          }

          if (result.paths[i].charAt(0) === '~') {
            result.paths[i] = result.paths[i].replace('~', os.homedir());
          }
        }

        projects.push(result);
      }

      if (callback) {
        callback(projects);
      }
    });
{'fraction_non_alphanumeric': 0.14840182648401826, 'fraction_numerical': 0.0006523157208088715, 'mean_word_length': 2.0366336633663367, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '5405067', 'n_tokens_mistral': 933, 'n_tokens_neox': 903, 'n_words': 212}