diff --git a/src/Fable.Cli/CHANGELOG.md b/src/Fable.Cli/CHANGELOG.md index ecbd7a77e7..8184976896 100644 --- a/src/Fable.Cli/CHANGELOG.md +++ b/src/Fable.Cli/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Fixed function composition types (by @ncave) * [GH-3668](https://github.com/fable-compiler/Fable/pull/3668) Normalize fable-library argument (by @nojaf) * [GH-3682](https://github.com/fable-compiler/Fable/pull/3682) Support some custom unary math operors (Acos, Asin, Atan, Atan2, Cos, Cosh, Exp, Log, Log2, Log10, Sin, Sinh, Sqrt, Tan, Tanh) (by @PierreYvesR) +* [GH-3603](https://github.com/fable-compiler/Fable/issues/3603) Port back fixes for missing `.gitignore` file in the generated `fable_modules/` folder (by @MangelMaxime) #### Javascript diff --git a/src/Fable.Compiler/ProjectCracker.fs b/src/Fable.Compiler/ProjectCracker.fs index 55b46d2b34..d576d11954 100644 --- a/src/Fable.Compiler/ProjectCracker.fs +++ b/src/Fable.Compiler/ProjectCracker.fs @@ -43,13 +43,13 @@ type CacheInfo = } static member GetPath(fableModulesDir: string, isDebug: bool) = - IO.Path.Combine( - fableModulesDir, - $"""project_cracked{if isDebug then - "_debug" - else - ""}.json""" - ) + let suffix = + if isDebug then + "_debug" + else + "" + + IO.Path.Combine(fableModulesDir, $"project_cracked%s{suffix}.json") member this.GetTimestamp() = CacheInfo.GetPath(this.FableModulesDir, this.FableOptions.DebugMode) @@ -173,6 +173,17 @@ type CrackerOptions(cliArgs: CliArgs) = fableModulesDir + member _.ResetFableModulesDir() = + if IO.Directory.Exists(fableModulesDir) then + IO.Directory.Delete(fableModulesDir, recursive = true) + + IO.Directory.CreateDirectory(fableModulesDir) |> ignore + + IO.File.WriteAllText( + IO.Path.Combine(fableModulesDir, ".gitignore"), + "**/*" + ) + type CrackerResponse = { FableLibDir: string @@ -1196,8 +1207,7 @@ let getFullProjectOpts (opts: CrackerOptions) = // The cache was considered outdated / invalid so it is better to make // make sure we have are in a clean state - if IO.Directory.Exists(opts.FableModulesDir) then - IO.Directory.Delete(opts.FableModulesDir, true) + opts.ResetFableModulesDir() let fableLibDir, pkgRefs = match opts.FableOptions.Language with