Skip to content

Commit

Permalink
fix: read packageJson.config.prefsPrefix for compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
northword committed Jan 6, 2025
1 parent 5561a0d commit 740dcaa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion packages/scaffold/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ function resolveConfig(config: Config): Context {
config.id ||= config.name;
config.namespace ||= config.name;
config.xpiName ||= kebabCase(config.name);
config.build.prefs.prefix ||= `extensions.${config.namespace}`;
// Patch to maintain compatibility for zotero-plugin-template users
config.build.prefs.prefix ||= pkgUser.config.prefsPrefix || `extensions.${config.namespace}`;

// Parse template strings in config
const isPreRelease = version.includes("-");
Expand Down
13 changes: 10 additions & 3 deletions packages/scaffold/src/core/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,20 @@ export default class Build extends Base {
for (const match of matchs) {
const [matched, key] = match;
if (!prefsWithoutPrefix[key] && !prefsWithoutPrefix[key]) {
this.logger.warn(`preference key '${key}' in ${path} not init in prefs.js`);
this.logger.warn(`preference key '${key}' in ${path.replace(`${dist}/`, "")} not init in prefs.js`);
continue;
}
if (key.startsWith(prefix))
if (key.startsWith(prefix)) {
continue;
else
}
// else if (key.startsWith("extensions.")) {
// this.logger.warn(`Pref key '${key}' in ${path} starts with 'extensions' but not ${prefix}.`);
// this.logger.debug(`Skip prefixing '${key}' since it starts with 'extensions'.`);
// continue;
// }
else {
content = content.replace(matched, `preference="${prefix}.${key}"`);
}
}
await outputFile(path, content, "utf-8");
}));
Expand Down

0 comments on commit 740dcaa

Please sign in to comment.