fix: insecure tmp path (#33)

Fixes #13
This commit is contained in:
Morten Olsen
2024-01-14 13:00:17 +01:00
committed by GitHub
parent 7436b3439c
commit 028b65587e
5 changed files with 15 additions and 5 deletions

View File

@@ -7,12 +7,13 @@ type ConfigValues = {
context?: string;
};
const paths = envPaths('mini-loader');
class Config {
#location: string;
#config?: ConfigValues;
constructor() {
const paths = envPaths('mini-loader');
this.#location = join(paths.config, 'config.json');
if (existsSync(this.#location)) {
this.#config = JSON.parse(readFileSync(this.#location, 'utf-8'));
@@ -23,6 +24,10 @@ class Config {
return this.#config?.context || 'default';
}
public get cacheLocation() {
return join(paths.cache, this.context);
}
public setContext = (context: string) => {
this.#config = {
...(this.#config || {}),