HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/buyercall_forms/buyercall/node_modules/karma-webpack/dist/mocha-env-loader.js
"use strict";

const sourceMap = require('source-map');

const loaderUtils = require('loader-utils');

const {
  SourceNode
} = sourceMap;
const {
  SourceMapConsumer
} = sourceMap;

module.exports = function mochaEnvLoader(content, map) {
  const options = Object.assign({}, loaderUtils.getOptions(this));
  const id = options.name;
  let sourceNode;

  if (!id) {
    return this.callback(null, content, map);
  }

  if (map) {
    sourceNode = SourceNode.fromStringWithSourceMap(content, new SourceMapConsumer(map));
  } else {
    const fileName = loaderUtils.getRemainingRequest(this);
    sourceNode = new SourceNode(null, null, null);
    content.split('\n').forEach((line, idx) => {
      sourceNode.add(new SourceNode(idx + 1, 0, fileName, `${line}\n`));
    });
    sourceNode.setSourceContent(fileName, content);
  }

  const concatSrc = new SourceNode();
  concatSrc.add([`describe(${JSON.stringify(id)}, function() {\n`, sourceNode, '\n});']);
  const result = concatSrc.toStringWithSourceMap();
  return this.callback(null, result.code, result.map.toString());
};