Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
kudu/Kudu.Core/Deployment/Generator/NodeSiteEnabler.cs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
65 lines (56 sloc)
2.22 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.IO; | |
using System.IO.Abstractions; | |
using Kudu.Core.Infrastructure; | |
namespace Kudu.Core.Deployment.Generator | |
{ | |
public static class NodeSiteEnabler | |
{ | |
private static readonly string[] IisStartupFiles = new[] | |
{ | |
"default.htm", "default.html", "default.asp", "index.htm", "index.html", "iisstart.htm", "default.aspx", "index.php" | |
}; | |
private static readonly string[] NodeDetectionFiles = new[] { "package.json" }; | |
private static readonly string[] PotentialNodeDetectionFiles = new[] { "server.js", "app.js" }; | |
public static bool LooksLikeNode(string siteFolder) | |
{ | |
bool potentiallyLooksLikeNode = false; | |
// If any of the files in NodeDetectionFiles exist | |
// We assume it's node.js | |
foreach (var nodeDetectionFile in NodeDetectionFiles) | |
{ | |
string fullPath = Path.Combine(siteFolder, nodeDetectionFile); | |
if (FileSystemHelpers.FileExists(fullPath)) | |
{ | |
return true; | |
} | |
} | |
// If any of the files in PotentialNodeDetectionFiles exist | |
// We assume it can potentially be node.js | |
foreach (var nodeDetectionFile in PotentialNodeDetectionFiles) | |
{ | |
string fullPath = Path.Combine(siteFolder, nodeDetectionFile); | |
if (FileSystemHelpers.FileExists(fullPath)) | |
{ | |
potentiallyLooksLikeNode = true; | |
break; | |
} | |
} | |
// If we assume it is potentially a node.js site | |
if (potentiallyLooksLikeNode) | |
{ | |
// Check if any of the known iis start pages exist | |
// If so, then it is not a node.js web site otherwise it is | |
foreach (var iisStartupFile in IisStartupFiles) | |
{ | |
string fullPath = Path.Combine(siteFolder, iisStartupFile); | |
if (FileSystemHelpers.FileExists(fullPath)) | |
{ | |
return false; | |
} | |
} | |
return true; | |
} | |
return false; | |
} | |
} | |
} |