Skip to content

Commit 36412e4

Browse files
committed
Stop AzureHelper throwing an exception if the emulator is already started or stopped.
1 parent 1d6610b commit 36412e4

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/app/FakeLib/AzureHelper.fs

+15-9
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,35 @@ type private AzureEmulatorParams = {
1616
let private AzureEmulatorDefaults = {
1717
StorageEmulatorToolPath =
1818
lazy
19-
let path = msSdkBasePath @@ "\Azure\Storage Emulator\AzureStorageEmulator.exe"
19+
let path = msSdkBasePath @@ @"\Azure\Storage Emulator\AzureStorageEmulator.exe"
2020
if fileExists path then path
2121
else failwith (sprintf "Unable to locate Azure Storage Emulator at %s" path)
2222
CSRunToolPath = "\"C:\Program Files\Microsoft SDKs\Windows Azure\Emulator\csrun.exe\""
2323
TimeOut = TimeSpan.FromMinutes 5.
2424
}
2525

26+
let private (|StorageAlreadyStarted|StorageAlreadyStopped|Ok|OtherError|) = function
27+
| 0 -> Ok
28+
| -5 -> StorageAlreadyStarted
29+
| -6 -> StorageAlreadyStopped
30+
| _ -> OtherError
31+
2632
/// Stops the storage emulator
2733
let StopStorageEmulator = (fun _ ->
28-
if 0 <> ExecProcess (fun info ->
34+
match ExecProcess (fun info ->
2935
info.FileName <- AzureEmulatorDefaults.StorageEmulatorToolPath.Value
30-
info.Arguments <- "stop") AzureEmulatorDefaults.TimeOut
31-
then
32-
failwithf "Azure Emulator Failure on stop Storage Emulator"
36+
info.Arguments <- "stop") AzureEmulatorDefaults.TimeOut with
37+
| Ok | StorageAlreadyStopped -> ()
38+
| _ -> failwithf "Azure Emulator Failure on stop Storage Emulator"
3339
)
3440

3541
/// Starts the storage emulator
3642
let StartStorageEmulator = (fun _ ->
37-
if 0 <> ExecProcess (fun info ->
43+
match ExecProcess (fun info ->
3844
info.FileName <- AzureEmulatorDefaults.StorageEmulatorToolPath.Value
39-
info.Arguments <- "start") AzureEmulatorDefaults.TimeOut
40-
then
41-
failwithf "Azure Emulator Failure on start Storage Emulator"
45+
info.Arguments <- "start") AzureEmulatorDefaults.TimeOut with
46+
| Ok | StorageAlreadyStarted -> ()
47+
| _ -> failwithf "Azure Emulator Failure on start Storage Emulator"
4248
)
4349

4450
/// Stops the compute emulator

0 commit comments

Comments
 (0)