public IEnumerable<IGooseAction> Create(ActionConfiguration configuration, IEnumerable<string> files) { if (configuration.IsValid) { foreach (var file in files) { var workingDirectory = Path.Combine(configuration.ProjectRoot, configuration.RelativeWorkingDirectory); var environmentVariables = new CommandEvironmentVariables(file); var command = this.commandBuilder.Build(configuration, environmentVariables); yield return new PowerShellGooseAction(this.powerShellTaskFactory, command); if (!CommandScope.File.Equals(configuration.Scope)) { yield break; } } } }
public ShellCommand Build(ActionConfiguration configuration, CommandEvironmentVariables environmentVariables) { var solutionRoot = configuration.SolutionRoot; var projectRoot = configuration.ProjectRoot; var relativeWorkingDirectory = configuration.RelativeWorkingDirectory; var absoluteWorkingDirectory = Path.Combine(projectRoot, relativeWorkingDirectory); var absoluteFilePath = environmentVariables.FilePath; var relativeFilePath = string.IsNullOrEmpty(projectRoot) ? absoluteFilePath : absoluteFilePath.Replace(projectRoot, "").TrimStart('\\', '/'); var payload = configuration.Command .Replace("{absolute-file-path}", absoluteFilePath) .Replace("{relative-file-path}", relativeFilePath) .Replace("{solution-root}", solutionRoot) .Replace("{project-root}", projectRoot) .Replace("{working-directory}", absoluteWorkingDirectory); return new ShellCommand(absoluteWorkingDirectory, payload); }
public void Initialize(ISolutionProject project, ActionConfiguration watchConfiguration) { this.configuration = watchConfiguration; var projectPath = project.ProjectFilePath; if (this.configuration.IsValid && !string.IsNullOrWhiteSpace(projectPath)) { this.configuration = watchConfiguration; this.fileMonitor.MonitorProject(project.ProjectFilePath, watchConfiguration.Glob); } }
private IEnumerable<string> FilterFilesByScope(IEnumerable<string> projectFiles, IEnumerable<string> inProjectFiles, ActionConfiguration configuration, Trigger trigger) { if (CommandScope.File.Equals(configuration.Scope)) { return Trigger.Save.Equals(trigger) && inProjectFiles.Any() ? inProjectFiles : Enumerable.Empty<string>(); } if (CommandScope.Project.Equals(configuration.Scope)) { var isSaveTrigger = Trigger.Save.Equals(trigger) && (projectFiles.Any() || inProjectFiles.Any()); var isDeleteTrigger = Trigger.Delete.Equals(trigger) && inProjectFiles.Any(); return isSaveTrigger || isDeleteTrigger ? new[] {configuration.ProjectRoot} : Enumerable.Empty<string>(); } return Enumerable.Empty<string>(); }
public void WithConfiguration(ActionConfiguration configuration) { this.changeConsumer.Initialize(A.Dummy<ISolutionProject>(), configuration); }