Find an existing coverage file

@param {CoverageFile[]} source
@param {string}         filename

@returns {CoverageFile|null}
485744
function findCoverageFile (source, filename) {
  for (var i = 0; i < source.length; i++) {
    var file = source[i]
    if (file.filename === filename) {
      return file
    }
  }
  return null
}
731361
function getIncludedContent(fileName, css) {
      return fs.readFileAsync(dirname + fileName, {encoding: 'utf8'}).then(function(data) {
        if (css && conf.cssUrlReplacer) {
          data = data.replace(cssurl, function(matched, pref, theUrl, suf) {
            //console.log('readFileAsync, css replacer: ' + url + ', ' + theUrl);
            return pref + conf.cssUrlReplacer(theUrl) + suf;
          });
        }
        incfiles[fileName] = data;
      })
      .catch(function(e) {
        // If we can't read the file, just issue a console warning and continue.
        // Content for this file will not be inlined.
        console.warn('Inliner:\n' + e);
      });
    }
71252
function(source) {
      var result = [];

      while(source.length > 0) {
        if(result.length > 0) {
          var nextTarget = source.pop();

          for(var i=0; i<result.length; i++) {
            var targetFile = result[i];

            var dependencies = dependenciesMap[targetFile].dependencies;

            var dependencyMatch = matchPatternFromArray(dependencies, dependenciesMap[nextTarget].dependencyPath.pattern);

            if(dependencyMatch) {
              break;
            }
          }

          // move dependent file to front
          result.splice(i, 0, nextTarget);

        } else {
          result.push(source.pop());
        }
      }

      return result;
    }
1162993
function (fileName) {
            if (!file.exists(fileName)) {
                try {
                    //Try to find the path of the file thanks to node's require resolving.
                    fileName = nodeRequire.resolve(fileName);
                } catch(e) {}
            }
            return frontSlash(path.normalize(frontSlash(fs.realpathSync(fileName))));
        }
916170
function getFileNames(fileNames = [], componentName) {
  const defaultFileNames = {
    testFileName: `${defaultOptions.testFileName}.${componentName}`,
    componentFileName: componentName,
    styleFileName: componentName,
  }

  const formattedFileNames = Object.keys(fileNames).reduce(
    (acc, curr) => {
      acc[curr] = replaceKeys(fileNames[curr], componentName)
      return acc
    },
    { ...defaultFileNames }
  )

  return formattedFileNames
}
272783
function fileExists(filename) {
    var d = Promise.defer();

    fs.exists(filename, function(exists) {
        d.resolve(exists);
    });

    return d.promise;
}
1103312
function getAst(load, sourceMapFileName){
	if(load.ast) {
		return load.ast;
	}

	var fileName = sourceMapFileName || load.map && load.map.file;

	load.ast = esprima.parse(load.source.toString(), {
		loc: true,
		source: fileName || load.address
	});

	if(load.map) {
		sourceMapToAst(load.ast, load.map);
	}

	return load.ast;
}
700873
function getErrorSource(error) {
  var match = /\n    at [^(]+ \((.*):(\d+):(\d+)\)/.exec(error.stack);
  if (match) {
    var source = match[1];
    var line = +match[2];
    var column = +match[3];

    // Support the inline sourceContents inside the source map
    var contents = fileContentsCache[source];

    // Support files on disk
    if (!contents && fs && fs.existsSync(source)) {
      try {
        contents = fs.readFileSync(source, 'utf8');
      } catch (er) {
        contents = '';
      }
    }

    // Format the line from the original source code like node does
    if (contents) {
      var code = contents.split(/(?:\r\n|\r|\n)/)[line - 1];
      if (code) {
        return source + ':' + line + '\n' + code + '\n' +
          new Array(column).join(' ') + '^';
      }
    }
  }
  return null;
}
1313998
protected String getJSIncludeFile(String fileName) {

        StringBuffer result = new StringBuffer(8);
        result.append("<script type=\"text/javascript\" src=\"");
        result.append(fileName);
        result.append("\"></script>");
        return result.toString();
    }
706258
function filter(filename) {
	if (/^polymer-starter-kit-/.test(filename)) {
		filename = filename.slice(filename.indexOf('\/') + 1);
	}

	return /^__MACOSX\//.test(filename) ? null : filename;
}
1267687
function compile(fileNames, options, verbose) {
  const program = ts.createProgram(fileNames, options)
  const emitResult = program.emit()

  /* istanbul ignore next */
  if (verbose) {
    const allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics)

    allDiagnostics.forEach((diagnostic) => {
      if (diagnostic.file) {
        const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(
          diagnostic.start
        )
        const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")
        console.log(
          `${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`
        )
      } else {
        console.log(`${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`)
      }
    })
  }
}
1215973
function fileExists(fileName) {
        if (!fileName) {
            return false;
        }

        var filePath = PathUtils.resolveInRoot(outputFolder, fileName);
        return fs.existsSync(filePath);
    }
447257
private Result compile(File source, File target) throws ServiceException {
        AssetServices assetServices = ServiceLocator.getAssetServices();
        AssetInfo parser = assetServices.getAsset(NODE_PACKAGE + "/parser.js");
        if (parser == null)
            throw new ServiceException(ServiceException.NOT_FOUND, "Asset not found: " + parser);
        AssetInfo runner = assetServices.getAsset(NODE_PACKAGE + "/webpackRunner.js");
        if (runner == null)
            throw new ServiceException(ServiceException.NOT_FOUND, "Asset not found: " + runner);

        NodeJS nodeJS = NodeJS.createNodeJS();

        logger.info("Compiling " + source + " using NODE JS: " + nodeJS.getNodeVersion());
        V8Object fileObj = new V8Object(nodeJS.getRuntime()).add("file", runner.getFile().getAbsolutePath());
        JavaCallback callback = (receiver, parameters) -> fileObj;
        nodeJS.getRuntime().registerJavaMethod(callback, "getRunner");

        final Result parseResult = new Result();
        callback = (receiver, parameters) -> {
            V8Object resultObj = parameters.getObject(0);
            parseResult.status = resultObj.getString("status");
            parseResult.message = resultObj.getString("message");
            resultObj.release();
            return null;
        };
        nodeJS.getRuntime().registerJavaMethod(callback, "setParseResult");

        nodeJS.exec(parser.getFile());
        while (nodeJS.isRunning()) {
            nodeJS.handleMessage();
        }

        fileObj.release();
        nodeJS.release();

        if (!parseResult.status.equals("OK"))
            throw new ServiceException(runner + " -> " + parseResult);

        // run
        nodeJS = NodeJS.createNodeJS();
        V8Object inputObj = new V8Object(nodeJS.getRuntime());
        inputObj.add("source", source.getAbsolutePath());
        inputObj.add("root", assetServices.getAssetRoot().getAbsolutePath());
        inputObj.add("output", target.getAbsolutePath());
        inputObj.add("debug", logger.isDebugEnabled());
        inputObj.add("devMode", isDevMode());
        callback = (receiver, parameters) -> inputObj;
        nodeJS.getRuntime().registerJavaMethod(callback, "getInput");

        final Result webpackResult = new Result();
        callback = (receiver, parameters) -> {
            V8Object resultObj = parameters.getObject(0);
            webpackResult.status = resultObj.getString("status");
            webpackResult.message = resultObj.getString("message");
            resultObj.release();
            return null;
        };
        nodeJS.getRuntime().registerJavaMethod(callback, "setWebpackResult");

        nodeJS.exec(runner.getFile());
        while (nodeJS.isRunning()) {
            nodeJS.handleMessage();
        }
        inputObj.release();
        nodeJS.release();

        if (!webpackResult.status.equals("OK"))
            throw new ServiceException(source + " -> " + webpackResult);

        return webpackResult;
    }
1116124
function find(test, cwd, callback, one) {
  var results = []
  var current

  test = augment(test)

  if (!callback) {
    callback = cwd
    cwd = null
  }

  current = cwd ? resolve(cwd) : process.cwd()

  once()

  // Test a file and check what should be done with the resulting file.
  function handle(filePath) {
    var file = toVFile(filePath)
    var result = test(file)

    if (mask(result, INCLUDE)) {
      if (one) {
        callback(null, file)
        return true
      }

      results.push(file)
    }

    if (mask(result, BREAK)) {
      callback(null, one ? null : results)
      return true
    }
  }

  // Check one directory.
  function once(child) {
    if (handle(current) === true) {
      return
    }

    readdir(current, onread)

    function onread(error, entries) {
      var length = entries ? entries.length : 0
      var index = -1
      var entry

      if (error) {
        entries = []
      }

      while (++index < length) {
        entry = entries[index]

        if (entry !== child && handle(resolve(current, entry)) === true) {
          return
        }
      }

      child = current
      current = dirname(current)

      if (current === child) {
        callback(null, one ? null : results)
        return
      }

      once(basename(child))
    }
  }
}
1111403
def file_source(self, filename):
        
        if self.cobertura1.has_file(filename) and \
                self.cobertura1.filesystem.has_file(filename):
            lines1 = self.cobertura1.source_lines(filename)
            line_statuses1 = dict(self.cobertura1.line_statuses(
                filename))
        else:
            lines1 = []
            line_statuses1 = {}

        lines2 = self.cobertura2.source_lines(filename)
        line_statuses2 = dict(self.cobertura2.line_statuses(filename))

        # Build a dict of lineno2 -> lineno1
        lineno_map = reconcile_lines(lines2, lines1)

        lines = []
        for lineno, source in enumerate(lines2, start=1):
            status = None
            reason = None
            if lineno not in lineno_map:
                # line was added or removed, just use whatever coverage status
                # is available as there is nothing to compare against.
                status = line_statuses2.get(lineno)
                reason = 'line-edit'
            else:
                other_lineno = lineno_map[lineno]
                line_status1 = line_statuses1.get(other_lineno)
                line_status2 = line_statuses2.get(lineno)
                if line_status1 is line_status2:
                    status = None  # unchanged
                    reason = None
                elif line_status1 is True and line_status2 is False:
                    status = False  # decreased
                    reason = 'cov-down'
                elif line_status1 is False and line_status2 is True:
                    status = True  # increased
                    reason = 'cov-up'

            line = Line(lineno, source, status, reason)
            lines.append(line)

        return lines
1242811
function (coverage /*, testName */) {
        var store = this.store;
        Object.keys(coverage).forEach(function (key) {
            var fileCoverage = coverage[key];
            if (store.hasKey(key)) {
                store.setObject(key, utils.mergeFileCoverage(fileCoverage, store.getObject(key)));
            } else {
                store.setObject(key, fileCoverage);
            }
        });
    }
168712
function findAssertionSourceInTrace(trace) {

    var found = null;

    for (var i = 0, l = trace.length; i < l; ++i) {
      if (
        trace[i].file === stSkipStart.file &&
        trace[i].line >= stSkipStart.line &&
        trace[i].line <= stSkipEnd.line
      ) {
        break;
      }
      found = trace[i];
    }

    return found;

  }