-
Notifications
You must be signed in to change notification settings - Fork 0
/
reload-assets.js
35 lines (31 loc) · 1.04 KB
/
reload-assets.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* Running this script will send a request to the web server
* to request reloading the asset manifest.
* Any changes to other files will require a restart.
*/
/** @type {import('axios').default} */
const axios = require('axios');
const fs = require('fs');
const path = require('path');
const yaml = require('yaml');
const config = yaml.parse(fs.readFileSync(path.join(__dirname, 'config.yml'), {
encoding: 'utf-8'
}));
function reload() {
if (!config.simofa_internals.dev) {
return console.error('Simofa is not in dev mode');
}
axios.get(`http://localhost:${config.port}/_dev/reload`).then((response) => {
console.log('Reloaded asset manifest. Response:', response.data);
}).catch((err) => {
if (err.code && err.code.startsWith('ECONN')) {
return console.error('Failed to reload asset manifest. Is Simofa online?');
}
console.error('Failed to reload asset manifest. Response:', err.response.data);
});
}
// Make it executable from the command line
if (require.main === module) {
reload();
}
module.exports.reload = reload;