Files
xboct-flow/src/storage/VscodeConfigProvider.ts
T

25 lines
935 B
TypeScript

import * as path from "path";
import * as vscode from "vscode";
import { getConfigSection, getSettingDefault } from "@/config";
import { IConfigProvider } from "@/ports";
export class VscodeConfigProvider implements IConfigProvider {
getProjectTaskPath(): string | undefined {
const workspaceRoot = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath;
if (!workspaceRoot) return undefined;
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(getConfigSection());
const globalPath =
config.get<string>("globalPath") ?? getSettingDefault("globalPath");
return globalPath || undefined;
}
}