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 path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
|
||||
export function getUserConfigDir() {
|
||||
if (process.platform === "win32") {
|
||||
@@ -18,11 +18,11 @@ export async function loadConfig(type) {
|
||||
switch (configType) {
|
||||
case "public":
|
||||
case "p":
|
||||
configFileName = "public-config.js";
|
||||
configFileName = "public-config.json";
|
||||
break;
|
||||
case "confidential":
|
||||
case "c":
|
||||
configFileName = "confidential-config.js";
|
||||
configFileName = "confidential-config.json";
|
||||
break;
|
||||
default:
|
||||
configFileName = null;
|
||||
@@ -35,7 +35,6 @@ export async function loadConfig(type) {
|
||||
}
|
||||
|
||||
const configPath = path.join(configBaseDir, "sk-az-tools", configFileName);
|
||||
const configUrl = pathToFileURL(configPath).href;
|
||||
const { config } = await import(configUrl);
|
||||
return config;
|
||||
const configJson = await readFile(configPath, "utf8");
|
||||
return JSON.parse(configJson);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user