Skip to content

Commit

Permalink
Fix run process
Browse files Browse the repository at this point in the history
  • Loading branch information
alfonsogarciacaro committed Sep 30, 2020
1 parent 943a571 commit c305e3c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
15 changes: 8 additions & 7 deletions src/Fable.Cli/Entry.fs
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,8 @@ let clean args dir =
argValue "--extension" args
|> Option.defaultValue CompilerOptionsHelper.DefaultFileExtension

let mutable fileCount = 0
let rec recClean dir =
IO.Directory.GetDirectories(dir)
|> Array.iter (fun subdir ->
if IO.Path.GetDirectoryName(subdir) = Naming.fableHiddenDir then
IO.Directory.Delete(subdir, true))

IO.Directory.GetFiles(dir)
|> Array.choose (fun file ->
if file.EndsWith(".fs") then Some(file.[.. (file.Length - 4)])
Expand All @@ -136,15 +132,20 @@ let clean args dir =
let file = filename + ext
if IO.File.Exists(file) then
IO.File.Delete(file)
fileCount <- fileCount + 1
Log.verbose(lazy ("Deleted " + file)))

IO.Directory.GetDirectories(dir)
|> Array.filter (fun subdir ->
ignoreDirs.Contains(IO.Path.GetFileName(subdir)) |> not)
|> Array.iter recClean
|> Array.iter (fun subdir ->
if IO.Path.GetFileName(subdir) = Naming.fableHiddenDir then
IO.Directory.Delete(subdir, true)
Log.always("Deleted " + File.getRelativePathFromCwd subdir)
else recClean subdir)

recClean dir
Log.always("Clean completed!")
Log.always("Clean completed! Files deleted: " + string fileCount)
0

let (|SplitCommandArgs|) (xs: string list) =
Expand Down
19 changes: 12 additions & 7 deletions src/Fable.Cli/Main.fs
Original file line number Diff line number Diff line change
Expand Up @@ -420,13 +420,19 @@ let rec startCompilation (changes: Set<string>) (state: State) = async {
| Some file -> Set.add file errors
| None -> errors) Set.empty

let state =
match state.CliArgs.RunArgs with
| Some runArgs ->
let hasError = not(Set.isEmpty newErrors)
let hasError, state =
match hasError, state.CliArgs.RunArgs, state.CliArgs.WatchMode with
// Only run process if there are no errors
| true, _, _ -> true, state
| false, None, _ -> false, state
| false, Some runArgs, true ->
Process.fireAndForget state.CliArgs.RootDir runArgs.ExeFile runArgs.Args
if runArgs.IsWatch then state
else { state with CliArgs = { state.CliArgs with RunArgs = None } }
| None -> state
if runArgs.IsWatch then false, state
else false, { state with CliArgs = { state.CliArgs with RunArgs = None } }
| false, Some runArgs, false ->
let exitCode = Process.runSync state.CliArgs.RootDir runArgs.ExeFile runArgs.Args
exitCode <> 0, state

match state.CliArgs.WatchMode, state.TestInfo with
| true, _ ->
Expand All @@ -448,7 +454,6 @@ let rec startCompilation (changes: Set<string>) (state: State) = async {
|> startCompilation changes

| false, None ->
let hasError = not(Set.isEmpty newErrors)
return if not hasError then Ok() else Error()

| false, Some info ->
Expand Down

0 comments on commit c305e3c

Please sign in to comment.