Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for Agnostic livereload with Entr
Zenika profile imagePierre-Yves Aillet
Pierre-Yves Aillet forZenika

Posted on • Edited on • Originally published atpyaillet.gitlab.io

     

Agnostic livereload with Entr

Entr overview

Today, I would like to introduce you to the projectentr.
I discovered this project randomly a while ago, but I had been searching for a tool
like this for a while.

The goal of this tool is to provide a simple command which can launch
a specified command when some files are modified.
Concretely, this tool can be useful if you are searching for an alternative to
livereload, but not related to a specific language and not related to a full
blownIDE

Example

I often use it to automatically launch tests forGolang projects I am
developping.

Imagine, I wish to test the following function in the
pkg.go file:

// Inc returns the op1 integer incremented by one unitfuncInc(op1int)int{returnop1+1}
Enter fullscreen modeExit fullscreen mode

I wish to test it, with this test inpkg_test.go:

funcTest_Inc(t*testing.T){actual:=Inc(1)ifactual!=2{t.Errorf("Expecting: <2>, got <%d>",actual)}}
Enter fullscreen modeExit fullscreen mode

I would launch my tests continuously with the following command:

find*.go | entr-c-s"go test ."
Enter fullscreen modeExit fullscreen mode

Here is a live preview of the result (using asciinema):

At first, the test is not working, but as soon as the test file is updated, the
test is launched again.
The specificity here, is to use the-c flag, in order to clear the screen
before launching the new command.

You can find the full list of optionshere

How does it work ?

In order to avoidpolling,
entr uses file system events
(kqueue with BSD,
inotify with Linux).

The full source code is available here:

GitHub logo eradman / entr

Run arbitrary commands when files change

How to get it ?

If you wish to install it, it's really easy, just use your Linux distribution package:

Ubuntu, Debian, Mint, ... :

$ apt install entr
Enter fullscreen modeExit fullscreen mode

Centos, ... :

$ yum install entr
Enter fullscreen modeExit fullscreen mode

MacOS :

$ brew install entr
Enter fullscreen modeExit fullscreen mode

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

More fromZenika

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp