This is very confusing as seen in #12974 or #12906. My suggestion would be "legacy."
try {
    var stat = fs.lstatSync(filePath);
    return stat.isFile();
  } catch (e) {
    return false;
  }
}
function checkDir(dirPath) {
  try {
    var stat = fs.lstatSync(dirPath);
    return stat.isDirectory();
  } catch (e) {
    return false;
  }
}
function replaceInFile(filePath, find, replacement) {
  var content = fs.readFileSync(filePath).toString();
  content = content.replace(find, replacement);
  fs.writeFileSync(filePath, content);
}
function getTempFile(prefix, suffix) {
  mkdirp.sync(BUILD_DIR + "tmp/");
  var bytes = require("crypto").randomBytes(6).toString("hex");
  var filePath = BUILD_DIR + "tmp/" + prefix + bytes + suffix;
  fs.writeFileSync(filePath, "");
  return filePath;
}
function createTestSource(testsName, bot) {