/// <summary> /// Run Clean process /// </summary> /// <returns></returns> protected override StageCompletionStatusEnum ExecuteProcess() { // See if the Root directory exists ControlFlow.Assert(FileSystemTasks.DirectoryExists(CISession.RootDirectory), "Root Directory does not exist. Should be specified on command line or be run from the projects entry folder"); // See if slugci directory exists. if (!CISession.IsInSetupMode) { if (!FileSystemTasks.DirectoryExists(CISession.SlugCIPath) || !FileSystemTasks.FileExists(CISession.SlugCIFileName)) { AOT_Error("Are you in the Repository root folder - where .git folder for the project is located at?"); AOT_Error("Either change to the root folder of the project or run with --setup flag"); return(StageCompletionStatusEnum.Aborted); } } // Load the SlugCI Config for the project CISession.SlugCIConfigObj = SlugCIConfig.LoadFromFile(CISession.SlugCIFileName); if (!CISession.IsInSetupMode && CISession.SlugCIConfigObj == null) { CompletionStatus = StageCompletionStatusEnum.Failure; ControlFlow.Assert(CISession.SlugCIConfigObj != null, "Failure loading the SlugCI Configuration file - [ " + CISession.SlugCIFileName + " ]"); } // See if version of config matches the version of SlugCI (our current instance) if (!CISession.IsInSetupMode) { if (SlugCIConfig.CONFIG_STRUCTURE_VERSION != CISession.SlugCIConfigObj.ConfigStructureVersion) { // if ( CISession.SlugCI_Version != CISession.SlugCIConfigObj.ConfigStructureVersion ) { AOT_Warning("The version of the SlugCIConfig object does not match the current SlugCI version. Setup will need to be run."); CISession.IsInSetupMode = true; return(StageCompletionStatusEnum.Warning); } } CheckForEnvironmentVariables(); return(StageCompletionStatusEnum.Success); }
/// <summary> /// Returns the first directory that exists on disk /// </summary> /// <remarks> /// Caches the result for faster lookups later /// </remarks> /// <param name="paths"></param> /// <returns></returns> public static AbsolutePath PickDirectory(params AbsolutePath[] paths) { foreach (var path in paths) { if (_cache.TryGetValue(path, out var _)) { return(path); } if (!FileSystemTasks.DirectoryExists(path)) { continue; } foreach (var p in paths) { _cache.TryAdd(p, path); } return(path); } return(paths.First()); }