internal IFile Build() { // Inside our manifest model we normalize on Posix path syntax so that any manifest // errors regarding any file path uses the same syntax used by the manifest file. var path = new PurePosixPath(this.Path); // If either output directory or name isn't given, derive it from the source path. var outputDirectory = this.OutputDirectory ?? path.Directory; var outputName = this.OutputName ?? path.Filename; // There shouldn't be any directory component in the output name. var outputNamePath = new PurePosixPath(outputName); if (!string.IsNullOrEmpty(outputNamePath.Directory)) { throw new NotSupportedException($"Output name {outputName} must not specify any directory components."); } return(new File( path.ToString(), this.Computed, new ComputedString(outputDirectory), new ComputedString(outputName) )); }
public void ItCanReadSimpleFileFromManifest() { SetManifest(@" name: FooTemplate version: 1.0.0 files: - path: path/to/file.txt "); var t = this.TemplateLoader.LoadFromTemplateDirectory(TestTemplatePath); t.Files.Count.Should().Be(1); var f = t.Files.First(); f.Path.Should().Be("path/to/file.txt"); f.Computed.Should().BeFalse(); f.OutputDirectory.Value.Should().Be("path/to"); f.OutputName.Value.Should().Be("file.txt"); var outputPath = new PurePosixPath(f.OutputDirectory.Value, f.OutputName.Value); f.Path.Should().Be(outputPath.ToString()); }