internal static string DeterminePrimaryScriptFile(JObject functionConfig, string[] functionFiles)
{
if (functionFiles.Length == 1)
{
// if there is only a single file, that file is primary
return functionFiles[0];
}
else
{
// First see if there is an explicit primary file indicated
// in config. If so use that.
string functionPrimary = null;
string scriptFileName = (string)functionConfig["scriptFile"];
if (!string.IsNullOrEmpty(scriptFileName))
{
functionPrimary = functionFiles.FirstOrDefault(p =>
string.Compare(Path.GetFileName(p), scriptFileName, StringComparison.OrdinalIgnoreCase) == 0);
}
else
{
// if there is a "run" file, that file is primary,
// for Node, any index.js file is primary
functionPrimary = functionFiles.FirstOrDefault(p =>
Path.GetFileNameWithoutExtension(p).ToLowerInvariant() == "run" ||
Path.GetFileName(p).ToLowerInvariant() == "index.js");
}
return functionPrimary;
}
}