<commit_before>import { BuildContext, BuildOptions, generateContext, generateBuildOptions, Logger } from './util';
import { bundle, bundleUpdate } from './bundle';
import { clean } from './clean';
import { minify } from './minify';
import { copy } from './copy';
import { lint } from './lint';
import { ngc } from './ngc';
import { sass, sassUpdate } from './sass';
import { tsc } from './tsc';


export function build(context: BuildContext, options: BuildOptions) {
  context = generateContext(context);
  options = generateBuildOptions(options);

  const logger = new Logger(`build ${(options.isProd ? 'prod' : 'dev')}`);

  const promises: Promise<any>[] = [];

  if (options.isProd) {
    // production build
    promises.push(buildProd(context, options));

  } else {
    // dev build
    promises.push(buildDev(context, options));
  }

  return Promise.all(promises).then(() => {
    // congrats, we did it!  (•_•) / ( •_•)>⌐■-■ / (⌐■_■)
    return logger.finish();

  }).catch(err => {
    return logger.fail(err, 'Build failed' + (err.message ? ': ' + err.message : ''));
  });
}


function buildProd(context: BuildContext, options: BuildOptions) {
  // sync empty the www directory
  clean();

  // async tasks
  // these can happen all while other tasks are running
  const copyPromise = copy();
  const lintPromise = lint();

  return ngc(context, options).then(() => {
    return bundle(context, options);

  }).then(() => {
    return sass(context);

  }).then(() => {
    return minify(context);

  }).then(() => {
    // ensure the async tasks have fully completed before resolving
    return Promise.all([
      copyPromise,
      lintPromise
    ]);
  });
}


function buildDev(context: BuildContext, options: BuildOptions) {
  // sync empty the www directory
  clean();

  // async tasks
  // these can happen all while other tasks are running
  const copyPromise = copy();
  const lintPromise = lint();

  return tsc(context, options).then(() => {<commit_msg>fix(context): pass same context to all build tasks<commit_after>import { BuildContext, BuildOptions, generateContext, generateBuildOptions, Logger } from './util';
import { bundle, bundleUpdate } from './bundle';
import { clean } from './clean';
import { minify } from './minify';
import { copy } from './copy';
import { lint } from './lint';
import { ngc } from './ngc';
import { sass, sassUpdate } from './sass';
import { tsc } from './tsc';


export function build(context: BuildContext, options: BuildOptions) {
  context = generateContext(context);
  options = generateBuildOptions(options);

  const logger = new Logger(`build ${(options.isProd ? 'prod' : 'dev')}`);

  const promises: Promise<any>[] = [];

  if (options.isProd) {
    // production build
    promises.push(buildProd(context, options));

  } else {
    // dev build
    promises.push(buildDev(context, options));
  }

  return Promise.all(promises).then(() => {
    // congrats, we did it!  (•_•) / ( •_•)>⌐■-■ / (⌐■_■)
    return logger.finish();

  }).catch(err => {
    return logger.fail(err, 'Build failed' + (err.message ? ': ' + err.message : ''));
  });
}


function buildProd(context: BuildContext, options: BuildOptions) {
  // sync empty the www directory
  clean(context);

  // async tasks
  // these can happen all while other tasks are running
  const copyPromise = copy(context);
  const lintPromise = lint(context);

  return ngc(context, options).then(() => {
    return bundle(context, options);

  }).then(() => {
    return sass(context);

  }).then(() => {
    return minify(context);

  }).then(() => {
    // ensure the async tasks have fully completed before resolving
    return Promise.all([
      copyPromise,
      lintPromise
    ]);
  });
}


function buildDev(context: BuildContext, options: BuildOptions) {
  // sync empty the www directory
  clean(context);

  // async tasks
  // these can happen all while other tasks are running
  const copyPromise = copy(context);
  const lintPromise = lint(context);

  return tsc(context, options).then(() => {
{'fraction_non_alphanumeric': 0.16084262701363072, 'fraction_numerical': 0.0, 'mean_word_length': 3.4646017699115044, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '5779158', 'n_tokens_mistral': 1231, 'n_tokens_neox': 1200, 'n_words': 359}