gruntjs - Execute shell command (grunt build) with FAKE (F# make) -


i want automate build process of project using fake requires me run grunt task.

in particular, want create target runs grunt build task in subfolder of solution folder. due lack of f# knowledge, not able pass multiple parameters static exec method of shell class. https://fsharp.github.io/fake/apidocs/fake-processhelper-shell.html

this have got far:

target "rungrunt" (fun _ ->        let errorcode = shell.exec "grunt" "build" "\frontend"       ()  ) 

this fails following error message:

build.fsx(38,23): error fs0003: value not function , cannot applied 

if remove last 2 parameters, works, fails find grunt @ runtime:

system.componentmodel.win32exception (0x80004005): system cannot find file specified    @ system.diagnostics.process.startwithcreateprocess(processstartinfo startinfo)    @ system.diagnostics.process.start()    @ fake.processhelper.start(process proc) in c:\code\fake\src\app\fakelib\processhelper.fs:line 22    @ fake.processhelper.asyncshellexec@424-2.invoke(process _arg1) in c:\code\fake\src\app\fakelib\processhelper.fs:line 428    @ microsoft.fsharp.control.asyncbuilderimpl.calla@851.invoke(asyncparams`1 args) --- end of stack trace previous location exception thrown ---    @ microsoft.fsharp.control.asyncbuilderimpl.commit[a](result`1 res)    @ microsoft.fsharp.control.cancellationtokenops.runsynchronously[a](cancellationtoken token, fsharpasync`1 computation, fsharpoption`1 timeout)    @ microsoft.fsharp.control.fsharpasync.runsynchronously[t](fsharpasync`1 computation, fsharpoption`1 timeout, fsharpoption`1 cancellationtoken)    @ fsi_0001.build.clo@34-6.invoke(unit _arg5) in d:\development\repos\fmveav2\fmvea2-frontend\build.fsx:line 36    @ fake.targethelper.runsingletarget(targettemplate`1 target) in c:\code\fake\src\app\fakelib\targethelper.fs:line 483 

grunt included in path variable. (it works if called command line)

my questions are:

  1. how can pass multiple parameters shell.exec method?

  2. how run grunt, without including complete path it?

both problems solved.

  1. john pointed out in comment use tuple style instead of curried form results in following code:

    shell.exec( "grunt","build","\frontend")

  2. fake provides method find file on path. http://fsharp.github.io/fake/apidocs/fake-processhelper.html

the target definition therefore looks this:

target "rungrunt" (fun _ ->     let grunt = tryfindfileonpath if isunix "grunt" else "grunt.cmd"      let errorcode = match grunt                       | g -> shell.exec(g, "build", "frontend")                       | none -> -1     () ) 

neftedollar made point in comments cross platform compatiblity: using environmenthelper determine platform , search correct executable of grunt.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -