refactor: update names, load defaults from package.json
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import * as path from "path";
|
||||
import * as vscode from "vscode";
|
||||
import { getConfigSection, getSettingDefault } from "@/config";
|
||||
import { IConfigProvider } from "@/ports";
|
||||
|
||||
export class VscodeConfigProvider implements IConfigProvider {
|
||||
@@ -7,18 +8,24 @@ export class VscodeConfigProvider implements IConfigProvider {
|
||||
const workspaceRoot = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath;
|
||||
if (!workspaceRoot) return undefined;
|
||||
|
||||
const config = vscode.workspace.getConfiguration("xboctFlow");
|
||||
const relativePath = config.get<string>("projectPath") ?? ".vscode/tasks";
|
||||
const config = vscode.workspace.getConfiguration(getConfigSection());
|
||||
// get() already merges package.json defaults; fallback for safety.
|
||||
const relativePath =
|
||||
config.get<string>("projectPath") ?? getSettingDefault("projectPath");
|
||||
return path.join(workspaceRoot, relativePath);
|
||||
}
|
||||
|
||||
getGlobalTaskPath(): string | undefined {
|
||||
const config = vscode.workspace.getConfiguration("xboctFlow");
|
||||
return config.get<string>("globalPath") || undefined;
|
||||
const config = vscode.workspace.getConfiguration(getConfigSection());
|
||||
const globalPath =
|
||||
config.get<string>("globalPath") ?? getSettingDefault("globalPath");
|
||||
return globalPath || undefined;
|
||||
}
|
||||
|
||||
getFileExtension(): string {
|
||||
const config = vscode.workspace.getConfiguration("xboctFlow");
|
||||
return config.get<string>("fileExtension") ?? ".task.md";
|
||||
const config = vscode.workspace.getConfiguration(getConfigSection());
|
||||
return (
|
||||
config.get<string>("fileExtension") ?? getSettingDefault("fileExtension")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user