qa: add e2e tests

This commit is contained in:
Morten Olsen
2024-01-17 00:16:21 +01:00
parent e5064ca905
commit d3ad83ddf7
68 changed files with 1560 additions and 583 deletions

View File

@@ -1,20 +1,22 @@
import envPaths from 'env-paths';
import { existsSync, readFileSync, writeFileSync } from 'fs';
import { mkdir } from 'fs/promises';
import { existsSync, readFileSync } from 'fs';
import { mkdir, writeFile } from 'fs/promises';
import { join, dirname } from 'path';
import { ContainerInstance, Service } from 'typedi';
import { Paths } from '../paths/paths.js';
type ConfigValues = {
context?: string;
};
const paths = envPaths('mini-loader');
@Service()
class Config {
#paths: Paths;
#location: string;
#config?: ConfigValues;
constructor() {
this.#location = join(paths.config, 'config.json');
constructor(contianer: ContainerInstance) {
this.#paths = contianer.get(Paths);
this.#location = join(this.#paths.config, 'config.json');
if (existsSync(this.#location)) {
this.#config = JSON.parse(readFileSync(this.#location, 'utf-8'));
}
@@ -24,8 +26,12 @@ class Config {
return this.#config?.context || 'default';
}
public get location() {
return this.#paths.config;
}
public get cacheLocation() {
return join(paths.cache, this.context);
return join(this.#paths.cache, this.context);
}
public setContext = (context: string) => {
@@ -42,7 +48,7 @@ class Config {
}
const json = JSON.stringify(this.#config);
mkdir(dirname(this.#location), { recursive: true });
writeFileSync(this.#location, json);
writeFile(this.#location, json);
};
}