Task: multiline problem

Created on 20 Jan 2019  路  2Comments  路  Source: go-task/task

I have the following "make" task:

PKGS = $(shell go list ./... | grep -v /vendor/ | grep -v /bindata)

lint:
    golint $(PKGS)

How would I do the same with "task" ?

I tried many things like:

version: '2'

vars:
  PKGS:
    sh: go list ./... | grep -v /vendor/ | grep -v /bindata

tasks:
  lint:
    cmds:
      - golint {{.PKGS}}

or: - golint {{join .PKGS " "}} or - golint {{join " " .PKGS}}
but nothing works.

It execute:

golint myApp
myApp/pkg/actions
myApp/pkg/color
myApp/pkg/config

instead of:

golint myApp myApp/pkg/actions myApp/pkg/color myApp/pkg/config
question

All 2 comments

Hi @alaingilbert,

Unlike Make, Task doesn't automatically convert new lines into spaces on interpolation. But there's a helper method for that catLines:

version: '2'

vars:
  PKGS:
    sh: go list ./... | grep -v /vendor/ | grep -v /bindata

tasks:
  lint:
    cmds:
      - golint {{catLines .PKGS}}

This should do the trick.

Awesome, that works perfectly.

I had the following workaround | tr '\n' ' '
but I prefer the helper.

Was this page helpful?
0 / 5 - 0 ratings