<commit_before>import * as util from 'gulp-util';
import { existsSync, mkdirSync } from 'fs';
import { join } from 'path';

import Config from '../../config';

/**
 * Creates a source-map-explorer report with the given task name.
 * @param {string} taskName - The name of the task.
 */
export function createSME(taskName: string) {
  return (): void => {
    let exec = require('child_process').exec;
    let sme = './node_modules/.bin/source-map-explorer';

    let task = taskName.replace(/\./g, '_');
    let outFileName = `${task}_${now()}.${Config.SME_OUT_FORMAT}`;
    let out = join(Config.SME_DIR, outFileName);

    let appBundle = join(Config.JS_DEST, Config.JS_PROD_APP_BUNDLE);
    let appBundleMap = `${appBundle}.map`;

    if (!existsSync(Config.SME_DIR)) {
      mkdirSync(Config.SME_DIR);
    }
    exec(`${sme} --${Config.SME_OUT_FORMAT} ${appBundle} ${appBundleMap} > ${out}`,
      (error: Error, stdout: string, stderr: string) => {
        if (error !== null) {
          console.error(util.colors.red.bold('source-map-explorer error: ' + error + stderr));
          process.exit(1);
        }
      });
  };
}

function now(): string {
  let date = new Date();
  return new Date(date.getTime() - (date.getTimezoneOffset() * 60000))
    .toISOString()
    .replace(/[:.]/g, '_');
}<commit_msg>fix(tools): sme on windows<commit_after>import { exec } from 'child_process';
import * as util from 'gulp-util';
import { existsSync, mkdirSync } from 'fs';
import { join } from 'path';

import Config from '../../config';

const isWin = /^win/.test(process.platform);

/**
 * Creates a source-map-explorer report with the given task name.
 * @param {string} taskName - The name of the task.
 */
export function createSME(taskName: string) {
  return (): void => {
    let sme = './node_modules/.bin/source-map-explorer';

    if (isWin) {
      sme = '.\\node_modules\\.bin\\source-map-explorer.cmd';
    }

    const task = taskName.replace(/\./g, '_');
    const outFileName = `${task}_${now()}.${Config.SME_OUT_FORMAT}`;
    const out = join(Config.SME_DIR, outFileName);

    const appBundle = join(Config.JS_DEST, Config.JS_PROD_APP_BUNDLE);
    const appBundleMap = `${appBundle}.map`;

    if (!existsSync(Config.SME_DIR)) {
      mkdirSync(Config.SME_DIR);
    }
    exec(`${sme} --${Config.SME_OUT_FORMAT} ${appBundle} ${appBundleMap} > ${out}`,
      (error: Error, stdout: string, stderr: string) => {
        if (error !== null) {
          console.error(util.colors.red.bold('source-map-explorer error: ' + error + stderr));
          process.exit(1);
        }
      });
  };
}

function now(): string {
  const date = new Date();
  return new Date(date.getTime() - (date.getTimezoneOffset() * 60000))
    .toISOString()
    .replace(/[:.]/g, '_');
}
{'fraction_non_alphanumeric': 0.18028067650233898, 'fraction_numerical': 0.004318100035984167, 'mean_word_length': 3.1554559043348283, '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': '3793327', 'n_tokens_mistral': 953, 'n_tokens_neox': 941, 'n_words': 211}