<commit_before>/// <reference path="./broccoli-writer.d.ts" />
/// <reference path="../typings/node/node.d.ts" />
/// <reference path="../typings/fs-extra/fs-extra.d.ts" />
/// <reference path="./ts2dart.d.ts" />

import fs = require('fs');
import fse = require('fs-extra');
import path = require('path');
import ts2dart = require('ts2dart');
import {wrapDiffingPlugin, DiffingBroccoliPlugin, DiffResult} from './diffing-broccoli-plugin';

class TSToDartTranspiler implements DiffingBroccoliPlugin {
  static includeExtensions = ['.js', '.ts'];

  private basePath: string;
  private transpiler: ts2dart.Transpiler;

  constructor(public inputPath: string, public cachePath: string, public options) {
    options.basePath = inputPath;
    this.transpiler = new ts2dart.Transpiler(options);
  }

  rebuild(treeDiff: DiffResult) {
    let toEmit = [];
    let getDartFilePath = (path: string) => path.replace(/((\.js)|(\.ts))$/i, '.dart');
    treeDiff.changedPaths.forEach((changedPath) => {
      let inputFilePath = path.resolve(this.inputPath, changedPath);

      // Ignore files which don't need to be transpiled to Dart
      let dartInputFilePath = getDartFilePath(inputFilePath);
      if (fs.existsSync(dartInputFilePath)) return;

      // Prepare to rebuild<commit_msg>fix(build): only pass ts files to ts2dart transpilation.<commit_after>/// <reference path="./broccoli-writer.d.ts" />
/// <reference path="../typings/node/node.d.ts" />
/// <reference path="../typings/fs-extra/fs-extra.d.ts" />
/// <reference path="./ts2dart.d.ts" />

import fs = require('fs');
import fse = require('fs-extra');
import path = require('path');
import ts2dart = require('ts2dart');
import {wrapDiffingPlugin, DiffingBroccoliPlugin, DiffResult} from './diffing-broccoli-plugin';

class TSToDartTranspiler implements DiffingBroccoliPlugin {
  static includeExtensions = ['.ts'];

  private basePath: string;
  private transpiler: ts2dart.Transpiler;

  constructor(public inputPath: string, public cachePath: string, public options) {
    options.basePath = inputPath;
    this.transpiler = new ts2dart.Transpiler(options);
  }

  rebuild(treeDiff: DiffResult) {
    let toEmit = [];
    let getDartFilePath = (path: string) => path.replace(/((\.js)|(\.ts))$/i, '.dart');
    treeDiff.changedPaths.forEach((changedPath) => {
      let inputFilePath = path.resolve(this.inputPath, changedPath);

      // Ignore files which don't need to be transpiled to Dart
      let dartInputFilePath = getDartFilePath(inputFilePath);
      if (fs.existsSync(dartInputFilePath)) return;

      // Prepare to rebuild
{'fraction_non_alphanumeric': 0.15420200462606015, 'fraction_numerical': 0.004240555127216654, 'mean_word_length': 4.058479532163743, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, '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': '5506730', 'n_tokens_mistral': 839, 'n_tokens_neox': 812, 'n_words': 181}