Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace .fsproj with .fableproj in fable_modules #2557

Merged
merged 1 commit into from
Oct 1, 2021
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
22 changes: 16 additions & 6 deletions src/Fable.Cli/ProjectCracker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,14 @@ let createFableDir (opts: CrackerOptions) =

fableDir

let copyDirIfDoesNotExist (source: string) (target: string) =
// Replace the .fsproj extension with .fableproj for files in fable_modules
// We do this to avoid conflicts with other F# tooling that scan for .fsproj files
let changeFsprojToFableproj (path: string) =
if path.EndsWith(".fsproj") then
IO.Path.ChangeExtension(path, Naming.fableProjExt)
else path

let copyDirIfDoesNotExist replaceFsprojExt (source: string) (target: string) =
if isDirectoryEmpty target then
IO.Directory.CreateDirectory(target) |> ignore
if IO.Directory.Exists source |> not then
Expand All @@ -472,8 +479,10 @@ let copyDirIfDoesNotExist (source: string) (target: string) =
let target = target.TrimEnd('/', '\\')
for dirPath in IO.Directory.GetDirectories(source, "*", IO.SearchOption.AllDirectories) do
IO.Directory.CreateDirectory(dirPath.Replace(source, target)) |> ignore
for newPath in IO.Directory.GetFiles(source, "*.*", IO.SearchOption.AllDirectories) do
IO.File.Copy(newPath, newPath.Replace(source, target), true)
for fromPath in IO.Directory.GetFiles(source, "*.*", IO.SearchOption.AllDirectories) do
let toPath = fromPath.Replace(source, target)
let toPath = if replaceFsprojExt then changeFsprojToFableproj toPath else toPath
IO.File.Copy(fromPath, toPath, true)

let copyFableLibraryAndPackageSources (opts: CrackerOptions) (pkgs: FablePackage list) =
let fableLibDir = createFableDir opts
Expand Down Expand Up @@ -501,15 +510,16 @@ let copyFableLibraryAndPackageSources (opts: CrackerOptions) (pkgs: FablePackage

Log.verbose(lazy ("fable-library: " + fableLibrarySource))
let fableLibraryTarget = IO.Path.Combine(fableLibDir, "fable-library" + "." + Literals.VERSION)
copyDirIfDoesNotExist fableLibrarySource fableLibraryTarget
copyDirIfDoesNotExist false fableLibrarySource fableLibraryTarget
fableLibraryTarget

let pkgRefs =
pkgs |> List.map (fun pkg ->
let sourceDir = IO.Path.GetDirectoryName(pkg.FsprojPath)
let targetDir = IO.Path.Combine(fableLibDir, pkg.Id + "." + pkg.Version)
copyDirIfDoesNotExist sourceDir targetDir
{ pkg with FsprojPath = IO.Path.Combine(targetDir, IO.Path.GetFileName(pkg.FsprojPath)) })
copyDirIfDoesNotExist true sourceDir targetDir
let fsprojFile = IO.Path.GetFileName(pkg.FsprojPath) |> changeFsprojToFableproj
{ pkg with FsprojPath = IO.Path.Combine(targetDir, fsprojFile) })

fableLibraryPath, pkgRefs

Expand Down
1 change: 1 addition & 0 deletions src/Fable.Transforms/Global/Prelude.fs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ module Naming =
let [<Literal>] placeholder = "__PLACE-HOLDER__"
let [<Literal>] dummyFile = "__DUMMY-FILE__.txt"
let [<Literal>] fableHiddenDir = "fable_modules"
let [<Literal>] fableProjExt = ".fableproj"
let [<Literal>] unknown = "UNKNOWN"

let isInFableHiddenDir (file: string) =
Expand Down