fix(loadConfig): correct config file extensions from .js to .json and update loading method
This commit is contained in:
11
src/index.js
11
src/index.js
@@ -1,6 +1,6 @@
|
|||||||
|
import { readFile } from "node:fs/promises";
|
||||||
import os from "node:os";
|
import os from "node:os";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { pathToFileURL } from "node:url";
|
|
||||||
|
|
||||||
export function getUserConfigDir() {
|
export function getUserConfigDir() {
|
||||||
if (process.platform === "win32") {
|
if (process.platform === "win32") {
|
||||||
@@ -18,11 +18,11 @@ export async function loadConfig(type) {
|
|||||||
switch (configType) {
|
switch (configType) {
|
||||||
case "public":
|
case "public":
|
||||||
case "p":
|
case "p":
|
||||||
configFileName = "public-config.js";
|
configFileName = "public-config.json";
|
||||||
break;
|
break;
|
||||||
case "confidential":
|
case "confidential":
|
||||||
case "c":
|
case "c":
|
||||||
configFileName = "confidential-config.js";
|
configFileName = "confidential-config.json";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
configFileName = null;
|
configFileName = null;
|
||||||
@@ -35,7 +35,6 @@ export async function loadConfig(type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const configPath = path.join(configBaseDir, "sk-az-tools", configFileName);
|
const configPath = path.join(configBaseDir, "sk-az-tools", configFileName);
|
||||||
const configUrl = pathToFileURL(configPath).href;
|
const configJson = await readFile(configPath, "utf8");
|
||||||
const { config } = await import(configUrl);
|
return JSON.parse(configJson);
|
||||||
return config;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user