<commit_before>/**
 * @license
 * Copyright Google Inc. All Rights Reserved.
 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://angular.io/license
 */
import * as fs from 'fs';
import * as path from 'path';
import { BaseException } from '../src';
import { isFile } from './fs';

/**
 * Exception thrown when a module could not be resolved.
 */
export class ModuleNotFoundException extends BaseException {
  public readonly code: string;

  constructor(public readonly moduleName: string, public readonly basePath: string) {
    super(`Could not find module ${JSON.stringify(moduleName)} from ${JSON.stringify(basePath)}.`);
    this.code = 'MODULE_NOT_FOUND';
  }
}

/**
 * Returns a list of all the callers from the resolve() call.
 * @returns {string[]}
 * @private
 */
function _caller(): string[] {
  // see https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi
  const error = Error as {} as { prepareStackTrace: (x: {}, stack: {}) => {} };
  const origPrepareStackTrace = error.prepareStackTrace;
  error.prepareStackTrace = (_, stack) => stack;
  const stack = (new Error()).stack as {}[] | undefined as { getFileName(): string }[] | undefined;
  error.prepareStackTrace = origPrepareStackTrace;

  return stack ? stack.map(x => x.getFileName()) : [];
}


/**
 * Get the global directory for node_modules. This is based on NPM code itself, and may be subject
 * to change, but is relatively stable.
 * @returns {string} The path to node_modules itself.
 * @private
 */
function _getGlobalNodeModules() {
  let globalPrefix;

  if (process.env.PREFIX) {
    globalPrefix = process.env.PREFIX;
  } else if (process.platform === 'win32') {
    // c:\node\node.exe --> prefix=c:\node\
    globalPrefix = path.dirname(process.execPath);<commit_msg>fix(@angular-devkit/core): remove functions that have no files from caller array<commit_after>/**
 * @license
 * Copyright Google Inc. All Rights Reserved.
 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://angular.io/license
 */
import * as fs from 'fs';
import * as path from 'path';
import { BaseException } from '../src';
import { isFile } from './fs';

/**
 * Exception thrown when a module could not be resolved.
 */
export class ModuleNotFoundException extends BaseException {
  public readonly code: string;

  constructor(public readonly moduleName: string, public readonly basePath: string) {
    super(`Could not find module ${JSON.stringify(moduleName)} from ${JSON.stringify(basePath)}.`);
    this.code = 'MODULE_NOT_FOUND';
  }
}

/**
 * Returns a list of all the callers from the resolve() call.
 * @returns {string[]}
 * @private
 */
function _caller(): string[] {
  // see https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi
  const error = Error as {} as { prepareStackTrace: (x: {}, stack: {}) => {} };
  const origPrepareStackTrace = error.prepareStackTrace;
  error.prepareStackTrace = (_, stack) => stack;
  const stack = (new Error()).stack as {}[] | undefined as { getFileName(): string }[] | undefined;
  error.prepareStackTrace = origPrepareStackTrace;

  return stack ? stack.map(x => x.getFileName()).filter(x => !!x) : [];
}


/**
 * Get the global directory for node_modules. This is based on NPM code itself, and may be subject
 * to change, but is relatively stable.
 * @returns {string} The path to node_modules itself.
 * @private
 */
function _getGlobalNodeModules() {
  let globalPrefix;

  if (process.env.PREFIX) {
    globalPrefix = process.env.PREFIX;
  } else if (process.platform === 'win32') {
    // c:\node\node.exe --> prefix=c:\node\
    globalPrefix = path.dirname(process.execPath);
{'fraction_non_alphanumeric': 0.1366076221148685, 'fraction_numerical': 0.001610305958132045, 'mean_word_length': 3.8846657929226738, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, 'https://': 4, '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': '5619056', 'n_tokens_mistral': 1061, 'n_tokens_neox': 1052, 'n_words': 365}