Skip to content

Commit

Permalink
fix(plugins): custom variable must start with $_
Browse files Browse the repository at this point in the history
  • Loading branch information
sogehige committed Mar 6, 2024
1 parent dcb8b9c commit d707101
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/plugins/CustomVariable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,19 @@ import { setValueOf } from '~/helpers/customvariables/setValueOf.js';

export const CustomVariableGenerator = (pluginId: string) => ({
async set(variableName: string, value: any) {
await setValueOf(String(variableName), value, {});
variableName = String(variableName).trim();
if (variableName.startsWith('$_')) {
await setValueOf(variableName, value, {});
} else {
throw new Error('Variable name must start with "$_".');
}
},
async get(variableName: string) {
return getValueOf(String(variableName));
variableName = String(variableName).trim();
if (variableName.startsWith('$_')) {
return getValueOf(String(variableName));
} else {
throw new Error('Variable name must start with "$_".');
}
},
});

0 comments on commit d707101

Please sign in to comment.