Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions FSharpPacker.FSharp/Packer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ let ParsePaths paths =
type FsxLine =
| SourceCode of string
| Unsupported
| Skipped
| IncludePath of seq<string>
| IncludeFiles of seq<string>
| IncludeReference of references: seq<string> * packages: seq<NugetReference> * projectReferences: seq<string>
Expand Down Expand Up @@ -151,6 +152,8 @@ let classifyLine (sourceFile: SourceFile) (normalizedLine: string) =
let pathStrings = normalizedLine.Replace("#load ", "");
let files = ParsePaths(pathStrings) |> Seq.map sourceFile.ResolveRelativePath
IncludeFiles(files)
elif normalizedLine.StartsWith("#!") then
Skipped
else
SourceCode(normalizedLine)
else SourceCode(normalizedLine)
Expand All @@ -161,6 +164,7 @@ let rec public ProcessLine verbose state sourceFile line =
match lineResult with
| SourceCode(code) -> sourceFile.WriteLine(code)
| Unsupported -> ()
| Skipped -> ()
| AddNugetFeed(code) -> state.nugetSources <- Seq.append state.nugetSources [code]
| IncludePath(files) -> sourceFile.AddIncludePaths(files)
| IncludeFiles(files) -> for file in files do
Expand Down
3 changes: 3 additions & 0 deletions FSharpPacker.Tests/Samples/Shebang.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env -S dotnet fsi

printfn "Hello, world!"
11 changes: 11 additions & 0 deletions FSharpPacker.Tests/UnitTest1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,4 +245,15 @@ public void MultipleLoadDirectivesFile()

CollectionAssert.AreEqual(new string[] { "WithNamespace.fsx", "WithNamespaceAndComments.fsx", "Loader.fsx", "MultipleLoadDirectivesFile.fsx" }, preprocessor.GetSources().Select(_ => Path.GetFileName(_.FileName)).ToArray());
}
[TestMethod]
public void Shebang()
{
var sourceFile = "Samples/Shebang.fsx";
var preprocessor = new FsxPreprocessor(verbose: false);
preprocessor.AddSource(sourceFile);

preprocessor.Process();

Assert.AreEqual("module Shebang" + Environment.NewLine + Environment.NewLine + "printfn \"Hello, world!\"" + Environment.NewLine, preprocessor.GetSource(sourceFile));
}
}
Loading