Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

checksum and "start server" should always start the first time #232

Closed
frederikhors opened this issue Aug 6, 2019 · 4 comments
Closed
Labels
area: watcher Changes related to the Taskfile watcher. type: feature A new feature or functionality.

Comments

@frederikhors
Copy link
Contributor

If I have a task like this:

start_server:
  sources:
    - "**/*.go"
  method: checksum
  cmds:
    - go run ./cmd/app

it will run fine just the first time.

The second time (from command line launched with: task start_server -w) it will not because it prints:

Task "start_server" is up to date.

It should always start the first time I think, right?

@andreynering andreynering added the type: feature A new feature or functionality. label Aug 12, 2019
@andreynering
Copy link
Member

Hi @frederikhors,

I think I disagree. This makes sense for your use case (having a HTTP server up) but won't make sense for other use cases. For example, if you're watching a task that compiles a static web site, it makes sense to skip if it's already compile, even if you're using --watch.

I think you solve this by reworking your Taskfile like this:

version: '2'

tasks:
  run:
    deps: [build]
    cmds:
      - ./app

  build:
    cmds:
      - go build -v -o ./app ./cmd/app
    method: checksum
    sources:
      - '**/*.go'

This way, by watching run, it'll only compile if necessary, but always run.

@andreynering
Copy link
Member

@frederikhors Closing this since it's been almost a month.

If you still have questions, let me know.

@dschissler
Copy link

@frederikhors Create a task always-start and then add it as a dependency to the dev server task.

  dev:
    deps: [always-start, build:clean:generate, build:script]

  always-start:
    cmds:
      - echo "Always run" >/dev/null
    status: [ 1 = 0 ]
    silent: true

@andreynering andreynering added the area: watcher Changes related to the Taskfile watcher. label Aug 30, 2020
@saada
Copy link

saada commented Jul 27, 2024

For those running into this in 2024, you can now solve this by setting method: none

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: watcher Changes related to the Taskfile watcher. type: feature A new feature or functionality.
Projects
None yet
Development

No branches or pull requests

4 participants