fix(preferences): pass all command preferences to setCurrentPlugin

Previously, we were passing in only the plugin preferences. This means that when calling `getPreferenceValues`, none of the command preferences would be returned. This commit changes it to return *all* command preferences -- I do not think it will cause any problems, but we'll see I guess ¯\_(ツ)_/¯
This commit is contained in:
ByteAtATime 2025-06-25 22:01:54 -07:00
parent 2d40fee318
commit a561534075
No known key found for this signature in database

View file

@ -130,15 +130,7 @@ interface LaunchProps {
export const runPlugin = (pluginPath?: string, mode: 'view' | 'no-view' = 'view'): void => {
let pluginName = 'unknown';
let preferences: Array<{
name: string;
title: string;
description?: string;
type: 'textfield' | 'dropdown' | 'checkbox' | 'directory';
required?: boolean;
default?: string | boolean;
data?: Array<{ title: string; value: string }>;
}> = [];
let preferences: Preference[] = [];
if (!pluginPath) {
throw new Error('No plugin specified.');
@ -153,7 +145,11 @@ export const runPlugin = (pluginPath?: string, mode: 'view' | 'no-view' = 'view'
try {
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
pluginName = packageJson.name || path.basename(pluginDir);
preferences = packageJson.preferences || [];
const pluginPreferences = packageJson.preferences || [];
const allCommandPreferences = (packageJson.commands || []).flatMap(
(cmd: { preferences?: Preference[] }) => cmd.preferences || []
);
preferences = [...pluginPreferences, ...allCommandPreferences];
} catch (error) {
writeLog(`Error reading plugin package.json: ${error}`);
}