It seems you want some sort of conditional functionality in your build pipeline. You might find Make to be quite useful for this.
Under the hood, Make is a simple rule-based script engine. One of the main highlights of Make is the ease with which you’re able to instruct it to do something when a file changes.
For example, take a look at one of the Makefiles I have for a project:
# Makefile
OUT := bin/www
# Collect any file dependencies
FILES := $(shell find src -name "*")
$(OUT): Makefile $(FILES)
sh etc/build.sh
The Makefile declares the bin/www folder as the final target of the build script and assigns it at least one dependency: the Makefile itself. The FILES variable, when expanded, resolves to whatever files are found in the src directory; these files are then treated as dependencies themselves. If any one of the dependencies change (compared to the last successful build), Make will run the indented line—which itself executes another the main build script.
Hey @jaffathecake you can take a look at watch.json for some finer-grained control over what causes a project restart; we only completely restart the container itself every 12 hours. You could also put your compilation steps in the install script in package.json which would run those steps any time an install is required; watch.json can help you control that as well.
This feels like what I’m looking for, but I can’t find any docs for the install property of watch.json.
What is the default value for the install property? If I set an include value, am I overwriting that default, or is it being merged? Can there be an exclude property? Are there any other properties?
Sorry @jaffathecake, I think I was less than clear; the installscript property is in package.json and tells your project what commands to run during the install process. watch.json can help you control which changes to files trigger the install script.
Both install and restart follow the same patterns in watch.json, so should support both includes and excludes. Your settings in a local watch,json file override whatever Glitch would normally do in these cases.
My intent here is "If any file changes, except those in the .data directory, reinstall (by running npm run install). If only files in .data change, or the app simply needs restarting, run npm run start.
However, if I change files, it only seems to restart, it doesn’t rebuild.