Skip to content

Commit 740dcaa

Browse files
committed
fix: read packageJson.config.prefsPrefix for compatibility
1 parent 5561a0d commit 740dcaa

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

packages/scaffold/src/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ function resolveConfig(config: Config): Context {
4545
config.id ||= config.name;
4646
config.namespace ||= config.name;
4747
config.xpiName ||= kebabCase(config.name);
48-
config.build.prefs.prefix ||= `extensions.${config.namespace}`;
48+
// Patch to maintain compatibility for zotero-plugin-template users
49+
config.build.prefs.prefix ||= pkgUser.config.prefsPrefix || `extensions.${config.namespace}`;
4950

5051
// Parse template strings in config
5152
const isPreRelease = version.includes("-");

packages/scaffold/src/core/builder.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,13 +280,20 @@ export default class Build extends Base {
280280
for (const match of matchs) {
281281
const [matched, key] = match;
282282
if (!prefsWithoutPrefix[key] && !prefsWithoutPrefix[key]) {
283-
this.logger.warn(`preference key '${key}' in ${path} not init in prefs.js`);
283+
this.logger.warn(`preference key '${key}' in ${path.replace(`${dist}/`, "")} not init in prefs.js`);
284284
continue;
285285
}
286-
if (key.startsWith(prefix))
286+
if (key.startsWith(prefix)) {
287287
continue;
288-
else
288+
}
289+
// else if (key.startsWith("extensions.")) {
290+
// this.logger.warn(`Pref key '${key}' in ${path} starts with 'extensions' but not ${prefix}.`);
291+
// this.logger.debug(`Skip prefixing '${key}' since it starts with 'extensions'.`);
292+
// continue;
293+
// }
294+
else {
289295
content = content.replace(matched, `preference="${prefix}.${key}"`);
296+
}
290297
}
291298
await outputFile(path, content, "utf-8");
292299
}));

0 commit comments

Comments
 (0)