Comments (6)
The output from commands run by the trigger does to the watchman log file; it doesn't stay attached to your terminal.
I've made other comments about this before:
#20 (comment)
For your use case, I'd recommend that you use a wrapper script that calls make jshint
, because watchman is actually going to make jshint imageupload.js
-- it will pass a list of the files that changed to the make invocation and that probably isn't what you want.
Watchman is a bit different from the other watchers that are out there in that we run primarily as a background service. This makes it a bit more awkward to interact with in cases like this.
One of the things I'd like to see get added to watchman is a non-persistent client that subscribes to the service and runs ad-hoc triggers for itself. This would make it easier to use watchman for this use-case. We haven't had the bandwidth to add this feature yet.
from watchman.
For linting, you really need to see this in the foreground. If you're not afraid of doing some scripting, you could whip up the client for this pretty easily, here are some tips:
- Run
watchman get-sockname
to start watchman and locate the socket path - Open the unix socket returned from the above
- Send a JSON representation of your subscription of the unix socket; see https://github.com/facebook/watchman#command-subscribe the JSON object must be on one line
- Loop forever, reading lines back from the unix socket; when you get a JSON object with a
files
property, simply runmake jshint
and have it go to stdout/stderr
from watchman.
or just run jshint and pass it the files from the files
property
from watchman.
I'm closing this out due to lack of feedback. Happy to re-open and continue dialog if you still need some help.
from watchman.
I use make too to auto exec it when a file change. To redirect the output from watchman executed commands, I use a FIFO (also because I use nailgun, not shown it this example):
#!/usr/bin/make -f
# Get the directory where paths in this makefile are relative (this makefile directory)
PROJECT_DIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
# Watchman
WATCHMAN = watchman
SCRIPTS_SRC_DIR = scripts
SCRIPTS_SRC_PATTERN = $(SCRIPTS_SRC_DIR)/*.js
SCRIPTS_SRC_FILES = $(shell find $(SCRIPTS_SRC_DIR) -type f -name '*.js')
SCRIPTS_FILE = scripts.js
debug: clean $(SCRIPTS_FILE)
incremental-debug: $(SCRIPTS_FILE)
clean:
rm -f $(SCRIPTS_FILE)
watch: WATCHMANCMD = $(SHELL) -ilc "cd \"$(PROJECT_DIR)\"; $(MAKE) incremental-debug >> \"$(FIFONAME)\" 2>&1 &"
# We use fifo to pipe all logs in one place
watch: FIFONAME = ./.make$$PPID-fifo
watch: clean
ENDCMD='rm -f "$(FIFONAME)"; watchman watch-del "$(PROJECT_DIR)"';\
trap "echo '\n\033[1m[Interrupted]\033[0m'; echo \"$$ENDCMD\"; $$ENDCMD; exit 0" SIGINT SIGTERM SIGHUP SIGQUIT;\
mkfifo "$(FIFONAME)";\
$(WATCHMAN) watch "$(PROJECT_DIR)";\
$(WATCHMAN) -- trigger "$(PROJECT_DIR)" "make$$PPID" "$(SCRIPTS_SRC_PATTERN)" -- $(WATCHMANCMD);\
grep --line-buffered -v "Nothing to be done for" < "$(FIFONAME)"
# concatenate all JavaScript files
$(SCRIPTS_FILE): $(SCRIPTS_SRC_FILES)
cat $^ > $@
.PHONY: watch clean debug incremental-debug
make watch
will watch file change and execute make incremental-debug
and output result in the initial terminal.
To stop it just hit Ctrl+C or close the terminal.
from watchman.
Hello.
Even this doesn't work in make file. Why? But watchman-make works well.
watchman -- trigger ~/www jsfiles '*.js' -- ls -l
from watchman.
Related Issues (20)
- watchman on riscv
- why watchman does not support query base on time frame and sorting ability?
- Impossible to install on Amazonlinux HOT 2
- Folly related build issue for ARM Ubuntu 18.04.5 LTS
- Missing RPMs in Release v2023.04.24.00
- WatchMan Error on Docker. Watchman-make is not accessible even after installation.
- "Settle" behavior blocks entire file tree during long running zip operation
- Unable to compile with fmt 10.0.0
- Unable to talk to your watchman on /opt/homebrew/var/run/watchman/[user]-state/sock! HOT 8
- serde_bser: Apache-2.0 license file missing from git repo and published crates
- No Mac OS X binary
- Watchman ignores platform-specific path separators in `dirname` expressions
- Watchman root is set to /Users/<username> despite being run from a different directory HOT 1
- Ubuntu packags missing since May HOT 3
- "I don't know how to install any packages on this system linux-mint-21.2"
- Watchman warns on custom_config example line
- Installation guide HOT 2
- Question - `hint_num_files_per_dir` recursive or not?
- Watchman service is timing out waiting for a synchronization cookie file to be observed by the watcher within 20000 milliseconds HOT 2
- Deploy on winget
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from watchman.