Hi,
I have had to come back to an old project after a nine month break, and now my watcher is no longer working for my front end. The only thing that has changed, that I am aware of, is an OS upgrade on my MBP to Ventura 13.6.
My front end is Elm with some custom JS.
My setup is as follows:
I use elm-watch to watch my .elm files and build my Elm JS file when there is a change to my Elm files. This is working as expected, and it does rebuild my Elm app to my assets/js folder.
I then have a custom watcher (dev-release.js) which is referenced in my config/dev.exs file to watch for changes to all my assets/js files, and when a change is detected, copies the relevant file to a front-end-releases folder which is at the root of my project. These are the files that are loaded by templates/layout/app.html.eex.
My problem appears to be that my dev-release.js watcher is not working at all - I have logging in this file that is not appearing in the terminal.
The relevant lines in my dev.exs are as follows:
watchers: [
node: [
"node_modules/webpack/bin/webpack.js",
"--mode",
"development",
"--watch-stdin",
cd: Path.expand("../assets", __DIR__)
],
node: [
"./dev-release.js",
cd: Path.expand("../assets", __DIR__)
]
],
My dev-release.js:
const fs = require('fs');
const chokidar = require("chokidar");
const { execSync } = require("child_process");
const log = console.log.bind(console);
// Exit the process when standard input closes due to:
// https://hexdocs.pm/elixir/1.10.2/Port.html#module-zombie-operating-system-processes
//
process.stdin.on("end", function () {
log("standard input end");
process.exit();
});
process.stdin.resume();
/*
***** WATCH *****
*/
[
"bootstrap",
"elm",
"elm-app",
"elm-flags",
"elm-internal-messages",
"elm-jsstore",
"elm-pep",
"elm-phoenix-websocket",
"intersection-observer",
"jsstore",
"orientation-change",
"themes",
"token"
].forEach(watch);
function watch(filename) {
const watcher = chokidar.watch("./js/" + filename + ".js", {
ignored: /(^|[\/\\])\../, // ignore dotfiles
persistent: true
})
watcher
.on("change", releaseFile)
function releaseFile(path) {
log("releaseFile");
var changedFilePath = path;
try {
fs.readFile("../version-control/versions.json", 'utf8', (err, data) => {
if (err) {
console.error(err)
return
}
var versions = JSON.parse(data)
var target = changedFilePath.split("/")[1].split(".")[0]
var version = versions[target].version
var outputDir = "../" + versions[target].path + "/" + target + "/" + version
fs.mkdir(outputDir, { recursive: true }, function (error, path) {
if (path) {
log("-----> created dir -> " + path)
}
})
var targetFile = "./js/" + target + ".js"
var outputFile = outputDir + "/" + target + ".min.js";
fs.copyFile(targetFile, outputFile, function () {
log("-----> copied " + targetFile + " -> " + outputFile)
log("-----> Version: " + version)
})
})
} catch (error) { console.error(error) }
}
}
Anyone have any ideas why my watcher is no longer working?






















