diff --git a/package.json b/package.json index bad17a50..423a68ab 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "lint": "vue-cli-service lint", "pm2-start": "npx pm2 start server.js", "build-watch": "vue-cli-service build --watch --mode production", - "watch-config": "chokidar \"public/conf.yml\" --command \"npm run build\"", + "watch-config": "node services/watch-for-changes", "build-and-start": "NODE_OPTIONS=--openssl-legacy-provider npm-run-all --parallel watch-config start", "validate-config": "node services/config-validator", "health-check": "node services/healthcheck", @@ -24,7 +24,6 @@ "@sentry/vue": "^7.102.1", "ajv": "^8.10.0", "axios": "^1.6.0", - "chokidar-cli": "^3.0.0", "connect-history-api-fallback": "^1.6.0", "crypto-js": "^4.2.0", "express": "^4.17.2", diff --git a/services/watch-for-changes.js b/services/watch-for-changes.js new file mode 100644 index 00000000..c7faec2b --- /dev/null +++ b/services/watch-for-changes.js @@ -0,0 +1,20 @@ +const fs = require('fs'); +const { exec } = require('child_process'); + +const configFile = './public/conf.yml'; + +console.log(`Watching for file changes on ${configFile}`); + +fs.watch(configFile, (eventType, filename) => { + if (filename && eventType === 'change') { + console.log(`${filename} file Changed, running build...`); + exec('yarn build', (error, stdout, stderr) => { + if (error) { + console.error(`exec error: ${error}`); + return; + } + console.log(`stdout: ${stdout}`); + console.error(`stderr: ${stderr}`); + }); + } +}); diff --git a/yarn.lock b/yarn.lock index f53e4e4a..d888702a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2824,17 +2824,7 @@ check-types@^8.0.3: resolved "https://registry.yarnpkg.com/check-types/-/check-types-8.0.3.tgz#3356cca19c889544f2d7a95ed49ce508a0ecf552" integrity sha512-YpeKZngUmG65rLudJ4taU7VLkOCTMhNl/u4ctNC56LQS/zJTyNH0Lrtwm1tfTsbLlwvlfsA2d1c8vCf/Kh2KwQ== -chokidar-cli@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/chokidar-cli/-/chokidar-cli-3.0.0.tgz#29283666063b9e167559d30f247ff8fc48794eb7" - integrity sha512-xVW+Qeh7z15uZRxHOkP93Ux8A0xbPzwK4GaqD8dQOYc34TlkqUhVSS59fK36DOp5WdJlrRzlYSy02Ht99FjZqQ== - dependencies: - chokidar "^3.5.2" - lodash.debounce "^4.0.8" - lodash.throttle "^4.1.1" - yargs "^13.3.0" - -"chokidar@>=3.0.0 <4.0.0", chokidar@^3.4.1, chokidar@^3.5.2: +"chokidar@>=3.0.0 <4.0.0", chokidar@^3.4.1: version "3.6.0" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.6.0.tgz#197c6cc669ef2a8dc5e7b4d97ee4e092c3eb0d5b" integrity sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw== @@ -6144,11 +6134,6 @@ lodash.templatesettings@^4.0.0: dependencies: lodash._reinterpolate "^3.0.0" -lodash.throttle@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4" - integrity sha512-wIkUCfVKpVsWo3JSZlc+8MB5it+2AN5W8J7YVMST30UrvcQNZ1Okbj+rbVniijTWE6FGYy4XJq/rHkas8qJMLQ== - lodash.transform@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash.transform/-/lodash.transform-4.6.0.tgz#12306422f63324aed8483d3f38332b5f670547a0" @@ -10029,7 +10014,7 @@ yargs-parser@^20.2.2: resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== -yargs@^13.3.0, yargs@^13.3.2: +yargs@^13.3.2: version "13.3.2" resolved "https://registry.yarnpkg.com/yargs/-/yargs-13.3.2.tgz#ad7ffefec1aa59565ac915f82dccb38a9c31a2dd" integrity sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw==