Skip to content

Commit

Permalink
#901 fixes for project type parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Jand42 committed Feb 9, 2018
1 parent 7538d77 commit 5fae1ea
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/compiler/WebSharper.CSharp/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ let rec compileMain (argv: string[]) =
wsArgs := { !wsArgs with WarnOnly = true }
| "--dce-" -> wsArgs := { !wsArgs with DeadCodeElimination = false }
| StartsWith "--ws:" wsProjectType ->
setProjectType <| ProjectType.Parse(wsProjectType)
wsArgs := { !wsArgs with ProjectType = ProjectType.Parse(wsProjectType) }
| "--dlres" -> wsArgs := { !wsArgs with DownloadResources = true }
| "--printjs" -> wsArgs := { !wsArgs with PrintJS = true }
| "--vserrors" ->
Expand Down
25 changes: 11 additions & 14 deletions src/compiler/WebSharper.Compiler/CommandTools.fs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ type WsConfig =
match c.ToLower() with
| "true" -> Some false
| "movetotop" -> Some true
| _ ->
failwith "Invalid value for AnalyzeClosures, value must be true or movetotop."
| _ -> failwith "Invalid value for AnalyzeClosures, value must be true or movetotop."

member this.AddJson(jsonString) =
let json =
Expand All @@ -118,30 +117,28 @@ type WsConfig =
let settings =
match json with
| Json.Object values -> values
| _ -> failwith "Failed to parse wsconfig.json, not a json object."
let projectDir = Path.GetDirectoryName this.ProjectFile
let getPath k v =
| _ -> failwith "Failed to parse wsconfig.json, not a json object."
let getString k v =
match v with
| Json.String s ->
Path.Combine(projectDir, s)
| _ ->
failwithf "Invalid value in wsconfig.json for %s, expecting a string." k
| Json.String s -> s
| _ -> failwithf "Invalid value in wsconfig.json for %s, expecting a string." k
let projectDir = Path.GetDirectoryName this.ProjectFile
let getPath k v =
Path.Combine(projectDir, getString k v)
let getBool k v =
match v with
| Json.True -> true
| Json.False -> false
| Json.String s ->
match bool.TryParse s with
| true, b -> b
| _ ->
failwithf "Invalid value in wsconfig.json for %s, expecting true or false." k
| _ ->
failwithf "Invalid value in wsconfig.json for %s, expecting true or false." k
| _ -> failwithf "Invalid value in wsconfig.json for %s, expecting true or false." k
| _ -> failwithf "Invalid value in wsconfig.json for %s, expecting true or false." k
let mutable res = this
for k, v in settings do
match k.ToLower() with
| "project" ->
res <- { res with ProjectType = ProjectType.Parse (getPath k v) }
res <- { res with ProjectType = ProjectType.Parse (getString k v) }
| "outputdir" ->
res <- { res with OutputDir = Some (getPath k v) }
| "dce" ->
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/WebSharper.FSharp/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ let compileMain argv =
| "--wswarnonly" -> wsArgs := { !wsArgs with WarnOnly = true }
| "--dce-" -> wsArgs := { !wsArgs with DeadCodeElimination = false }
| StartsWith "--ws:" wsProjectType ->
setProjectType <| ProjectType.Parse(wsProjectType)
wsArgs := { !wsArgs with ProjectType = ProjectType.Parse(wsProjectType) }
| "--dlres" -> wsArgs := { !wsArgs with DownloadResources = true }
| "--printjs" -> wsArgs := { !wsArgs with PrintJS = true }
| "--vserrors" ->
Expand Down

0 comments on commit 5fae1ea

Please sign in to comment.