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
6 changes: 6 additions & 0 deletions src/Fable.Cli/Entry.fs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ let knownCliArgs () =
[ "--yes" ], [ "Automatically reply 'yes' (e.g. with `clean` command)" ]
[ "--noRestore" ], [ "Skip `dotnet restore`" ]
[ "--noCache" ], [ "Recompile all files, including sources from packages" ]
[ "--noGitignore" ],
[
"Don't generate a `.gitignore` file in the `fable_modules` folder"
"(Useful when publishing the compiled output, e.g. to npm)"
]
[ "--exclude" ],
[
"Don't merge sources of referenced projects with specified pattern"
Expand Down Expand Up @@ -366,6 +371,7 @@ type Runner =
SourceMapsRoot = args.Value "--sourceMapsRoot"
NoRestore = args.FlagEnabled "--noRestore"
NoCache = args.FlagEnabled "--noCache"
NoGitignore = args.FlagEnabled "--noGitignore"
// TODO: If we select optimize we cannot have F#/Fable parallelization
NoParallelTypeCheck = args.FlagEnabled "--noParallelTypeCheck"
Exclude = args.Values "--exclude"
Expand Down
13 changes: 9 additions & 4 deletions src/Fable.Compiler/ProjectCracker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ type CacheInfo =
let getFableModulesFromDir (baseDir: string) : string =
IO.Path.Combine(baseDir, Naming.fableModules) |> Path.normalizePath

let getFableModulesFromProject (projDir: string, outDir: string option, noCache: bool, evaluateOnly: bool) : string =
let getFableModulesFromProject
(projDir: string, outDir: string option, noCache: bool, noGitignore: bool, evaluateOnly: bool)
: string
=
let fableModulesDir =
outDir |> Option.defaultWith (fun () -> projDir) |> getFableModulesFromDir

Expand All @@ -95,15 +98,16 @@ let getFableModulesFromProject (projDir: string, outDir: string option, noCache:
if File.isDirectoryEmpty fableModulesDir then
IO.Directory.CreateDirectory(fableModulesDir) |> ignore

IO.File.WriteAllText(IO.Path.Combine(fableModulesDir, ".gitignore"), "**/*")
if not noGitignore then
IO.File.WriteAllText(IO.Path.Combine(fableModulesDir, ".gitignore"), "**/*")

fableModulesDir

type CrackerOptions(cliArgs: CliArgs, evaluateOnly: bool) =
let projDir = IO.Path.GetDirectoryName cliArgs.ProjectFile

let fableModulesDir =
getFableModulesFromProject (projDir, cliArgs.OutDir, cliArgs.NoCache, evaluateOnly)
getFableModulesFromProject (projDir, cliArgs.OutDir, cliArgs.NoCache, cliArgs.NoGitignore, evaluateOnly)

let builtDlls = HashSet()

Expand Down Expand Up @@ -157,7 +161,8 @@ type CrackerOptions(cliArgs: CliArgs, evaluateOnly: bool) =

IO.Directory.CreateDirectory(fableModulesDir) |> ignore

IO.File.WriteAllText(IO.Path.Combine(fableModulesDir, ".gitignore"), "**/*")
if not cliArgs.NoGitignore then
IO.File.WriteAllText(IO.Path.Combine(fableModulesDir, ".gitignore"), "**/*")

type CrackerResponse =
{
Expand Down
1 change: 1 addition & 0 deletions src/Fable.Compiler/Util.fs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type CliArgs =
Configuration: string
NoRestore: bool
NoCache: bool
NoGitignore: bool
NoParallelTypeCheck: bool
SourceMaps: bool
SourceMapsRoot: string option
Expand Down
1 change: 1 addition & 0 deletions src/Fable.Compiler/Util.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type CliArgs =
Configuration: string
NoRestore: bool
NoCache: bool
NoGitignore: bool
NoParallelTypeCheck: bool
SourceMaps: bool
SourceMapsRoot: string option
Expand Down
1 change: 1 addition & 0 deletions tests/Integration/Compiler/Util/Compiler.fs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ module Compiler =
SourceMapsRoot = None
NoRestore = false
NoCache = false
NoGitignore = false
NoParallelTypeCheck = false
Exclude = ["Fable.Core"]
Replace = Map.empty
Expand Down
Loading