public void AnalyzeFiles(bool readSubDictionaries = true) { string[] fileEntries = Directory.GetFiles(FolderPath); var fileNodes = fileEntries .Select(filePath => { var node = new FileNode(filePath); node.BuildDepGraph(); return(node); }) .ToList(); Files.AddRange(fileNodes); if (!readSubDictionaries) { return; } IList <string> subdirectoryEntries = Directory.GetDirectories(FolderPath) .Where(e => !e.Contains('.') && !e.Contains("node_modules")) .ToList(); var subFolderNodes = subdirectoryEntries.Select(subDirPath => { var node = new FolderNode(subDirPath); node.AnalyzeFiles(); return(node); }).ToList(); SubDictionaries.AddRange(subFolderNodes); }
static void Main(string[] args) { if (!args.Any()) { throw new IOException("You need to define a path!"); } var folderPath = args[0]; var rootFolder = new FolderNode(folderPath); rootFolder.AnalyzeFiles(); var allDependencies = FileHelper.DepsToFile; using StreamWriter sw = new StreamWriter(folderPath + Path.DirectorySeparatorChar + "dependencies.json"); sw.Write(JsonConvert.SerializeObject(allDependencies, Formatting.Indented)); sw.Close(); }