mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 00:52:55 +00:00
feat: tests
This commit is contained in:
@@ -15,10 +15,11 @@
|
||||
*/
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import {execSync} from 'child_process';
|
||||
import * as Dockerode from 'dockerode';
|
||||
import type {ContainerInfo} from 'dockerode';
|
||||
import mustache from 'mustache';
|
||||
import {asyncReadFile, asyncWriteFile} from './common.js';
|
||||
import {getContainers, getTemplateView} from './main.js';
|
||||
import {readFile, writeFile} from 'fs/promises';
|
||||
import {configFile} from './common.js';
|
||||
|
||||
/* eslint-disable unicorn/prefer-module */
|
||||
|
||||
@@ -39,14 +40,11 @@ async function updateNginxConfig() {
|
||||
const containers = await getContainers();
|
||||
|
||||
const containerHash = containers
|
||||
.map((container: Dockerode.ContainerInfo) => {
|
||||
.map((container: ContainerInfo) => {
|
||||
return container.Id;
|
||||
})
|
||||
.join(',');
|
||||
|
||||
delete require.cache[require.resolve('config')];
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const configFile = require('config');
|
||||
const configHash = JSON.stringify(configFile);
|
||||
|
||||
// if containers changed -> write config file, reload nginx
|
||||
@@ -57,7 +55,7 @@ async function updateNginxConfig() {
|
||||
|
||||
// render nginx config file
|
||||
const nginxConfig = mustache.render(
|
||||
await asyncReadFile('nginx.conf.template', 'utf8'),
|
||||
await readFile('nginx.conf.template', 'utf8'),
|
||||
await getTemplateView(containers),
|
||||
);
|
||||
|
||||
@@ -67,7 +65,7 @@ async function updateNginxConfig() {
|
||||
Logger.log(`Writing new config file "${configFile.output}"`);
|
||||
|
||||
// overwrite nginx config file with our rendered one
|
||||
await asyncWriteFile(configFile.output, nginxConfig, 'utf8');
|
||||
await writeFile(configFile.output, nginxConfig, 'utf8');
|
||||
|
||||
Logger.log('Executing "nginx -s reload" to tell nginx to reload the configuration file');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user