Skip to content

Commit

Permalink
Publish fable-compiler 2.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
alfonsogarciacaro committed Nov 29, 2018
1 parent 57d7598 commit 7c1513c
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 38 deletions.
2 changes: 1 addition & 1 deletion build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ let githubRelease releaseNotesDir () =

// release on github
createClient user pw
|> createDraft gitOwner project release.NugetVersion (release.SemVer.PreRelease <> None) release.Notes
|> createRelease gitOwner project release.NugetVersion (release.SemVer.PreRelease <> None) release.Notes
// |> uploadFile (buildDir</>("FSharp.Compiler.Service." + release.NugetVersion + ".nupkg"))
|> releaseDraft
|> Async.RunSynchronously
Expand Down
63 changes: 42 additions & 21 deletions src/dotnet/Fable.Compiler/CLI/CLI.Util.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace Fable.CLI

module Literals =

let [<Literal>] VERSION = "2.1.0"
let [<Literal>] VERSION = "2.1.1"
let [<Literal>] CORE_VERSION = "2.0.2"
let [<Literal>] DEFAULT_PORT = 61225
let [<Literal>] FORCE = "force:"
Expand Down Expand Up @@ -173,26 +173,47 @@ module Process =
p.Start() |> ignore
p

let run workingDir fileName args =
let p =
Options()
|> start workingDir fileName args
p.WaitForExit()
match p.ExitCode with
| 0 -> ()
| c -> failwithf "Process %s %s finished with code %i" fileName args c

let tryRunAndGetOutput workingDir fileName args =
try
let p =
Options(redirectOutput=true)
|> start workingDir fileName args
let output = p.StandardOutput.ReadToEnd()
// printfn "%s" output
p.WaitForExit()
output
with ex ->
"ERROR: " + ex.Message
// Adapted from https://github.com/enricosada/dotnet-proj-info/blob/1e6d0521f7f333df7eff3148465f7df6191e0201/src/dotnet-proj/Program.fs#L155
let runCmd log errorLog workingDir exePath args =
log (workingDir + "> " + exePath + " " + (args |> String.concat " "))

let logOut = System.Collections.Concurrent.ConcurrentQueue<string>()
let logErr = System.Collections.Concurrent.ConcurrentQueue<string>()

let runProcess (workingDir: string) (exePath: string) (args: string) =
let psi = System.Diagnostics.ProcessStartInfo()
psi.FileName <- exePath
psi.WorkingDirectory <- workingDir
psi.RedirectStandardOutput <- true
psi.RedirectStandardError <- true
psi.Arguments <- args
psi.CreateNoWindow <- true
psi.UseShellExecute <- false

use p = new System.Diagnostics.Process()
p.StartInfo <- psi

p.OutputDataReceived.Add(fun ea -> logOut.Enqueue (ea.Data))
p.ErrorDataReceived.Add(fun ea -> logErr.Enqueue (ea.Data))

try
p.Start() |> ignore
p.BeginOutputReadLine()
p.BeginErrorReadLine()
p.WaitForExit()
p.ExitCode
with ex ->
errorLog ("Cannot run: " + ex.Message)
-1

let exitCode =
String.concat " " args
|> runProcess workingDir exePath

for x in logOut.ToArray() do log x
for x in logErr.ToArray() do errorLog x

exitCode

[<RequireQualifiedAccess>]
module Async =
Expand Down
9 changes: 6 additions & 3 deletions src/dotnet/Fable.Compiler/CLI/ProjectCracker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,12 @@ let fullCrack (projFile: string): CrackedFsproj =
// may have a different case, see #1227
let dllRefs = Dictionary(StringComparer.OrdinalIgnoreCase)
// Try restoring project
// TODO: Detect if `dotnet` is not installed globally? How does Dotnet.ProjInfo detect it?
Process.tryRunAndGetOutput (IO.Path.GetDirectoryName projFile) "dotnet" ("restore " + (IO.Path.GetFileName projFile))
|> Console.WriteLine
do
Process.runCmd
Console.WriteLine Console.WriteLine
(IO.Path.GetDirectoryName projFile)
"dotnet" ["restore"; IO.Path.GetFileName projFile]
|> ignore
let projOpts, projRefs, _msbuildProps =
ProjectCoreCracker.GetProjectOptionsFromProjectFile projFile
// let targetFramework =
Expand Down
4 changes: 4 additions & 0 deletions src/js/fable-compiler/RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 2.1.1

* Try not to stop compilation if `dotnet restore` fails.

### 2.1.0

* Release _stablish_ version
Expand Down
2 changes: 1 addition & 1 deletion src/js/fable-compiler/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/js/fable-compiler/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fable-compiler",
"version": "2.1.0",
"version": "2.1.1",
"main": "dist/index.js",
"description": "Fable compiler",
"keywords": [
Expand Down
13 changes: 2 additions & 11 deletions src/js/fable-compiler/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ function uuid() {
}
/* tslint:enable:no-bitwise */

function parseJson(json) {
try {
return JSON.parse(json);
} catch {
return json;
}
}

function getVersion(): string {
try {
return require("../package.json").version;
Expand Down Expand Up @@ -83,14 +75,13 @@ export default function start(cliArgs?: {}): ICompilerProxy {
input: child.stdout,
});
linereader.on("line", (data: string) => {
const pattern = /^JSON:([\w-]+):(.*)$/.exec(data);
const pattern = /^JSON:([\w-]+):/.exec(data);
if (pattern != null) {
const id = pattern[1];
const resolve = pending.get(id);
if (resolve != null) {
const response = parseJson(pattern[2]);
resolve(response);
pending.delete(id);
resolve(JSON.parse(data.substr(pattern[0].length)));
}
} else { // LOG
console.log(data);
Expand Down

0 comments on commit 7c1513c

Please sign in to comment.